package c.j.a.d.b.m;

import android.app.AlarmManager;
import android.os.Handler;
import android.os.SystemClock;
import android.text.TextUtils;
import c.j.a.d.b.b.i;
import c.j.a.d.b.d.e0;
import c.j.a.d.b.d.f0;
import c.j.a.d.b.d.l0;
import c.j.a.d.b.d.o;
import c.j.a.d.b.d.q;
import c.j.a.d.b.e.f;
import c.j.a.d.b.e.h;
import c.j.a.d.b.e.k;
import c.j.a.d.b.e.l;
import c.j.a.d.b.e.n;
import c.j.a.d.b.e.s;
import c.j.a.d.b.j.g;
import c.j.a.d.b.j.j;
import c.j.a.d.b.j.w;
import com.huawei.hms.framework.common.ContainerUtils;
import com.ss.android.socialbase.downloader.e.d;
import com.ss.android.socialbase.downloader.g.e;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import javax.net.ssl.SSLHandshakeException;

/* compiled from: DownloadRunnable */
public class c implements e, Runnable {
    public static final String I = c.class.getSimpleName();
    public f0 A;
    public volatile int B = 5;
    public boolean C = false;
    public boolean D = false;
    public String E;
    public long F;
    public long G;
    public final c.j.a.d.b.l.a H;
    public Future a;
    public final c.j.a.d.b.h.c b;
    public volatile boolean c = false;
    public AtomicInteger d;
    public final ArrayList<b> e = new ArrayList();
    public volatile f f;
    public boolean g;
    public boolean h;
    public boolean i;
    public boolean j;
    public boolean k;
    public final AtomicBoolean l;
    public volatile i m = i.RUN_STATUS_NONE;
    public final n n;
    public com.ss.android.socialbase.downloader.g.c o;
    public l p;
    public final l q;
    public k r;
    public final k s;
    public s t;
    public final h u;
    public AlarmManager v;
    public volatile com.ss.android.socialbase.downloader.e.a w;
    public c.j.a.d.b.i.h x;
    public c.j.a.d.b.i.f y;
    public l0 z;

    /* compiled from: DownloadRunnable */
    public class c extends Throwable {
        public String a;

        public c(c cVar, String str) {
            super(str);
            this.a = str;
        }
    }

    /* compiled from: DownloadRunnable */
    public class b implements e0 {
        public final /* synthetic */ AtomicBoolean a;

        public b(AtomicBoolean atomicBoolean) {
            this.a = atomicBoolean;
        }

        public void a() {
            synchronized (c.this) {
                this.a.set(true);
                c cVar = c.this;
                if (!cVar.K()) {
                    c.j.a.d.b.j.c B = c.j.a.d.b.e.b.B();
                    if (B != null) {
                        B.q(cVar.o.g0());
                    }
                }
            }
        }
    }

    /* compiled from: DownloadRunnable */
    public class a extends o {
        public void a(List<String> list) {
            int i = 1;
            if (!(list == null || list.isEmpty())) {
                this.a = true;
            }
            c cVar = c.this;
            Objects.requireNonNull(cVar);
            if (list != null && !list.isEmpty()) {
                com.ss.android.socialbase.downloader.g.c cVar2 = cVar.o;
                if (cVar.m != i.RUN_STATUS_WAITING_ASYNC_HANDLER) {
                    i = 0;
                }
                cVar2.j0 = list;
                if (list.size() > i) {
                    List list2 = cVar2.s;
                    if (list2 == null) {
                        cVar2.s = new ArrayList();
                    } else {
                        list2.clear();
                    }
                    cVar2.Z = false;
                    cVar2.P = 0;
                    while (i < cVar2.j0.size()) {
                        cVar2.s.add(cVar2.j0.get(i));
                        i++;
                    }
                }
                c.j.a.d.b.j.c B = c.j.a.d.b.e.b.B();
                if (B != null) {
                    B.q(cVar.o.g0());
                }
            }
        }
    }

    public c(c.j.a.d.b.h.c cVar, Handler handler) {
        Class cls = c.j.a.d.b.e.b.class;
        this.b = cVar;
        com.ss.android.socialbase.downloader.g.c cVar2 = cVar.a;
        this.o = cVar2;
        this.p = cVar.c;
        this.r = cVar.b;
        this.z = cVar.n;
        this.A = cVar.o;
        s sVar = cVar.p;
        if (sVar == null) {
            if (cVar2 != null) {
                String str = cVar2.B;
                if (!TextUtils.isEmpty(str)) {
                    sVar = new w(str);
                }
            }
            if (c.j.a.d.b.e.b.y == null) {
                synchronized (cls) {
                    if (c.j.a.d.b.e.b.y == null) {
                        c.j.a.d.b.e.b.y = new c.j.a.d.b.j.o();
                    }
                }
            }
            sVar = c.j.a.d.b.e.b.y;
        }
        this.t = sVar;
        this.H = c.j.a.d.b.l.a.d(this.o.g0());
        F();
        this.n = c.j.a.d.b.e.b.x();
        if (c.j.a.d.b.e.b.d == null) {
            synchronized (cls) {
                if (c.j.a.d.b.e.b.d == null) {
                    c.j.a.d.b.e.b.d = new g();
                }
            }
        }
        this.q = c.j.a.d.b.e.b.d;
        if (c.j.a.d.b.e.b.w == null) {
            synchronized (cls) {
                if (c.j.a.d.b.e.b.w == null) {
                    c.j.a.d.b.e.b.w = new c.j.a.d.b.j.f();
                }
            }
        }
        this.s = c.j.a.d.b.e.b.w;
        this.u = new h(cVar, handler);
        this.v = c.j.a.d.b.e.b.p();
        this.l = new AtomicBoolean(true);
    }

    /* JADX WARNING: Removed duplicated region for block: B:25:0x0044  */
    /* JADX WARNING: Missing block: B:21:0x003d, code skipped:
            if (r3 < (r0.s.size() - 1)) goto L_0x003f;
     */
    /* JADX WARNING: Missing block: B:30:0x0056, code skipped:
            if ((r5.getCause() instanceof javax.net.ssl.SSLHandshakeException) == false) goto L_0x0065;
     */
    /* JADX WARNING: Missing block: B:32:0x005e, code skipped:
            if (r4.o.O() == false) goto L_0x0065;
     */
    /* JADX WARNING: Missing block: B:34:0x0062, code skipped:
            if ((r5 instanceof com.ss.android.socialbase.downloader.e.g) == false) goto L_0x0066;
     */
    public boolean A(com.ss.android.socialbase.downloader.e.a r5) {
        /*
        r4 = this;
        r0 = c.j.a.d.b.n.a.H(r5);
        r1 = 1;
        if (r0 == 0) goto L_0x0017;
    L_0x0007:
        r5 = r4.g;
        if (r5 == 0) goto L_0x0016;
    L_0x000b:
        r5 = r4.c;
        if (r5 != 0) goto L_0x0016;
    L_0x000f:
        r5 = r4.o;
        c.j.a.d.b.n.a.n(r5, r1);
        r4.c = r1;
    L_0x0016:
        return r1;
    L_0x0017:
        r0 = r4.d;
        r2 = 0;
        if (r0 == 0) goto L_0x0022;
    L_0x001c:
        r0 = r0.get();
        if (r0 > 0) goto L_0x0060;
    L_0x0022:
        r0 = r4.o;
        r3 = r0.s;
        if (r3 == 0) goto L_0x0041;
    L_0x0028:
        r3 = r3.size();
        if (r3 <= 0) goto L_0x0041;
    L_0x002e:
        r3 = r0.Z;
        if (r3 == 0) goto L_0x003f;
    L_0x0032:
        r3 = r0.P;
        if (r3 < 0) goto L_0x0041;
    L_0x0036:
        r0 = r0.s;
        r0 = r0.size();
        r0 = r0 - r1;
        if (r3 >= r0) goto L_0x0041;
    L_0x003f:
        r0 = 1;
        goto L_0x0042;
    L_0x0041:
        r0 = 0;
    L_0x0042:
        if (r0 != 0) goto L_0x0060;
    L_0x0044:
        r0 = r5.a;
        r3 = 1011; // 0x3f3 float:1.417E-42 double:4.995E-321;
        if (r0 == r3) goto L_0x0058;
    L_0x004a:
        r0 = r5.getCause();
        if (r0 == 0) goto L_0x0065;
    L_0x0050:
        r0 = r5.getCause();
        r0 = r0 instanceof javax.net.ssl.SSLHandshakeException;
        if (r0 == 0) goto L_0x0065;
    L_0x0058:
        r0 = r4.o;
        r0 = r0.O();
        if (r0 == 0) goto L_0x0065;
    L_0x0060:
        r5 = r5 instanceof com.ss.android.socialbase.downloader.e.g;
        if (r5 != 0) goto L_0x0065;
    L_0x0064:
        goto L_0x0066;
    L_0x0065:
        r1 = 0;
    L_0x0066:
        return r1;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.b.m.c.A(com.ss.android.socialbase.downloader.e.a):boolean");
    }

    public void B(com.ss.android.socialbase.downloader.e.a aVar) {
        String str = I;
        StringBuilder g = c.b.a.a.a.g("onError:");
        g.append(aVar.getMessage());
        c.j.a.d.b.g.a.d(str, g.toString());
        this.m = i.RUN_STATUS_ERROR;
        this.w = aVar;
        e();
    }

    public final com.ss.android.socialbase.downloader.g.b C(long j) {
        com.ss.android.socialbase.downloader.g.b.b bVar = new com.ss.android.socialbase.downloader.g.b.b(this.o.g0());
        bVar.f = -1;
        bVar.b = 0;
        bVar.g = j;
        bVar.c = j;
        bVar.d = 0;
        bVar.e = this.o.T - j;
        return bVar.a();
    }

    public final boolean D(com.ss.android.socialbase.downloader.e.a aVar) {
        AtomicInteger atomicInteger = this.d;
        boolean z = true;
        if (atomicInteger != null) {
            if (atomicInteger.get() <= 0 || (aVar != null && aVar.a == 1070)) {
                if (this.o.G()) {
                    this.d.set(this.o.n);
                    this.o.i0(this.d.get());
                } else if (aVar == null || ((aVar.a != 1011 && (aVar.getCause() == null || !(aVar.getCause() instanceof SSLHandshakeException))) || !this.o.O())) {
                    B(new com.ss.android.socialbase.downloader.e.a(aVar.a, String.format("retry for exception, but current retry time : %s , retry Time %s all used, last error is %s", new Object[]{String.valueOf(this.d), String.valueOf(this.o.m), aVar.b})));
                    return true;
                } else {
                    this.d.set(this.o.m);
                    this.o.i0(this.d.get());
                    this.o.b0 = true;
                }
                z = false;
            }
            if (this.m != i.RUN_STATUS_RETRY_DELAY && z) {
                this.o.i0(this.d.decrementAndGet());
            }
            return false;
        }
        StringBuilder g = c.b.a.a.a.g("retry for exception, but retain retry time is null, last error is :");
        g.append(aVar.b);
        B(new com.ss.android.socialbase.downloader.e.a(1043, g.toString()));
        return true;
    }

    public int E() {
        com.ss.android.socialbase.downloader.g.c cVar = this.o;
        return cVar != null ? cVar.g0() : 0;
    }

    public final void F() {
        com.ss.android.socialbase.downloader.g.c cVar = this.o;
        if (cVar != null) {
            int i = cVar.m - cVar.F;
            if (i < 0) {
                i = 0;
            }
            AtomicInteger atomicInteger = this.d;
            if (atomicInteger == null) {
                this.d = new AtomicInteger(i);
            } else {
                atomicInteger.set(i);
            }
        }
    }

    /* JADX WARNING: Unknown top exception splitter block from list: {B:76:0x00db=Splitter:B:76:0x00db, B:60:0x009f=Splitter:B:60:0x009f} */
    /* JADX WARNING: Removed duplicated region for block: B:63:0x00a3 A:{Catch:{ all -> 0x00dc }} */
    /* JADX WARNING: Removed duplicated region for block: B:90:? A:{SYNTHETIC, RETURN} */
    /* JADX WARNING: Removed duplicated region for block: B:67:0x00c1  */
    /* JADX WARNING: Removed duplicated region for block: B:63:0x00a3 A:{Catch:{ all -> 0x00dc }} */
    /* JADX WARNING: Removed duplicated region for block: B:67:0x00c1  */
    /* JADX WARNING: Removed duplicated region for block: B:90:? A:{SYNTHETIC, RETURN} */
    /* JADX WARNING: Removed duplicated region for block: B:63:0x00a3 A:{Catch:{ all -> 0x00dc }} */
    /* JADX WARNING: Removed duplicated region for block: B:90:? A:{SYNTHETIC, RETURN} */
    /* JADX WARNING: Removed duplicated region for block: B:67:0x00c1  */
    /* JADX WARNING: Missing block: B:83:0x00e7, code skipped:
            if (r10.H.k(r0, false) != false) goto L_0x00e9;
     */
    public final void G() throws com.ss.android.socialbase.downloader.e.b {
        /*
        r10 = this;
        r0 = "fix_file_exist_update_download_info";
        r1 = 1;
        r2 = 0;
        r3 = r10.o;	 Catch:{ b -> 0x00d8, all -> 0x009c }
        r3 = r3.g0();	 Catch:{ b -> 0x00d8, all -> 0x009c }
        r4 = r10.n;	 Catch:{ b -> 0x00d8, all -> 0x009c }
        if (r4 == 0) goto L_0x0084;
    L_0x000e:
        r4 = 2048; // 0x800 float:2.87E-42 double:1.0118E-320;
        r4 = c.j.a.c.y.a.i.s(r4);	 Catch:{ b -> 0x00d8, all -> 0x009c }
        if (r4 == 0) goto L_0x001b;
    L_0x0016:
        r4 = r10.n;	 Catch:{ b -> 0x00d8, all -> 0x009c }
        r4.d();	 Catch:{ b -> 0x00d8, all -> 0x009c }
    L_0x001b:
        r4 = r10.n;	 Catch:{ b -> 0x00d8, all -> 0x009c }
        r4 = r4.b(r3);	 Catch:{ b -> 0x00d8, all -> 0x009c }
        if (r4 == 0) goto L_0x007e;
    L_0x0023:
        r5 = r4.o0();	 Catch:{ b -> 0x00d8, all -> 0x009c }
        if (r5 != 0) goto L_0x002b;
    L_0x0029:
        r5 = 1;
        goto L_0x002c;
    L_0x002b:
        r5 = 0;
    L_0x002c:
        if (r5 == 0) goto L_0x002f;
    L_0x002e:
        goto L_0x007e;
    L_0x002f:
        r5 = r10.o;	 Catch:{ b -> 0x00d8, all -> 0x009c }
        r6 = r5.e;	 Catch:{ b -> 0x00d8, all -> 0x009c }
        r7 = r5.y;	 Catch:{ b -> 0x00d8, all -> 0x009c }
        r5.s(r4, r1);	 Catch:{ b -> 0x00d8, all -> 0x009c }
        r5 = 4096; // 0x1000 float:5.74E-42 double:2.0237E-320;
        r5 = c.j.a.c.y.a.i.s(r5);	 Catch:{ b -> 0x00d8, all -> 0x009c }
        if (r5 == 0) goto L_0x0046;
    L_0x0040:
        r5 = r10.o;	 Catch:{ b -> 0x00d8, all -> 0x009c }
        if (r4 == r5) goto L_0x0046;
    L_0x0044:
        r5 = 1;
        goto L_0x0047;
    L_0x0046:
        r5 = 0;
    L_0x0047:
        r8 = r4.e;	 Catch:{ b -> 0x007c, all -> 0x007a }
        r6 = r6.equals(r8);	 Catch:{ b -> 0x007c, all -> 0x007a }
        if (r6 == 0) goto L_0x0067;
    L_0x004f:
        r6 = c.j.a.d.b.n.a.v(r4, r2, r7);	 Catch:{ b -> 0x007c, all -> 0x007a }
        if (r6 != 0) goto L_0x0056;
    L_0x0055:
        goto L_0x0067;
    L_0x0056:
        r3 = new com.ss.android.socialbase.downloader.e.b;	 Catch:{ b -> 0x0062, all -> 0x005e }
        r4 = r4.b;	 Catch:{ b -> 0x0062, all -> 0x005e }
        r3.m7695init(r4);	 Catch:{ b -> 0x0062, all -> 0x005e }
        throw r3;	 Catch:{ b -> 0x0062, all -> 0x005e }
    L_0x005e:
        r3 = move-exception;
        r1 = r3;
        r3 = 1;
        goto L_0x009f;
    L_0x0062:
        r3 = move-exception;
        r1 = r3;
        r3 = 1;
        goto L_0x00db;
    L_0x0067:
        r4 = c.j.a.d.b.e.b.b(r4);	 Catch:{ b -> 0x007c, all -> 0x007a }
        if (r4 == r3) goto L_0x0078;
    L_0x006d:
        r4 = r10.n;	 Catch:{ SQLiteException -> 0x0073 }
        r4.f(r3);	 Catch:{ SQLiteException -> 0x0073 }
        goto L_0x0085;
    L_0x0073:
        r3 = move-exception;
        r3.printStackTrace();	 Catch:{ b -> 0x007c, all -> 0x007a }
        goto L_0x0085;
    L_0x0078:
        r1 = r5;
        goto L_0x0085;
    L_0x007a:
        r1 = move-exception;
        goto L_0x0095;
    L_0x007c:
        r1 = move-exception;
        goto L_0x009a;
    L_0x007e:
        r3 = r10.o;	 Catch:{ b -> 0x00d8, all -> 0x009c }
        r3.P();	 Catch:{ b -> 0x00d8, all -> 0x009c }
        goto L_0x0085;
    L_0x0084:
        r1 = 0;
    L_0x0085:
        r10.F();	 Catch:{ b -> 0x0097, all -> 0x0092 }
        if (r1 == 0) goto L_0x00d7;
    L_0x008a:
        r0 = r10.n;	 Catch:{ SQLiteException -> 0x00d3 }
        r1 = r10.o;	 Catch:{ SQLiteException -> 0x00d3 }
        r0.a(r1);	 Catch:{ SQLiteException -> 0x00d3 }
        goto L_0x00d7;
    L_0x0092:
        r3 = move-exception;
        r5 = r1;
        r1 = r3;
    L_0x0095:
        r3 = 0;
        goto L_0x009f;
    L_0x0097:
        r3 = move-exception;
        r5 = r1;
        r1 = r3;
    L_0x009a:
        r3 = 0;
        goto L_0x00db;
    L_0x009c:
        r1 = move-exception;
        r3 = 0;
        r5 = 0;
    L_0x009f:
        r4 = r10.b;	 Catch:{ all -> 0x00dc }
        if (r4 == 0) goto L_0x00bf;
    L_0x00a3:
        r6 = r10.o;	 Catch:{ all -> 0x00dc }
        if (r6 == 0) goto L_0x00bf;
    L_0x00a7:
        r4 = r4.l;	 Catch:{ all -> 0x00dc }
        r7 = new com.ss.android.socialbase.downloader.e.a;	 Catch:{ all -> 0x00dc }
        r8 = 1003; // 0x3eb float:1.406E-42 double:4.955E-321;
        r9 = "checkTaskCache";
        r1 = c.j.a.d.b.n.a.B(r1, r9);	 Catch:{ all -> 0x00dc }
        r7.m4677init(r8, r1);	 Catch:{ all -> 0x00dc }
        r1 = r10.o;	 Catch:{ all -> 0x00dc }
        r1 = r1.o0();	 Catch:{ all -> 0x00dc }
        c.j.a.c.y.a.i.n(r4, r6, r7, r1);	 Catch:{ all -> 0x00dc }
    L_0x00bf:
        if (r5 == 0) goto L_0x00d7;
    L_0x00c1:
        if (r3 == 0) goto L_0x00cb;
    L_0x00c3:
        r1 = r10.H;	 Catch:{ SQLiteException -> 0x00d3 }
        r0 = r1.k(r0, r2);	 Catch:{ SQLiteException -> 0x00d3 }
        if (r0 == 0) goto L_0x00d7;
    L_0x00cb:
        r0 = r10.n;	 Catch:{ SQLiteException -> 0x00d3 }
        r1 = r10.o;	 Catch:{ SQLiteException -> 0x00d3 }
        r0.a(r1);	 Catch:{ SQLiteException -> 0x00d3 }
        goto L_0x00d7;
    L_0x00d3:
        r0 = move-exception;
        r0.printStackTrace();
    L_0x00d7:
        return;
    L_0x00d8:
        r1 = move-exception;
        r3 = 0;
        r5 = 0;
    L_0x00db:
        throw r1;	 Catch:{ all -> 0x00dc }
    L_0x00dc:
        r1 = move-exception;
        if (r5 == 0) goto L_0x00f5;
    L_0x00df:
        if (r3 == 0) goto L_0x00e9;
    L_0x00e1:
        r3 = r10.H;	 Catch:{ SQLiteException -> 0x00f1 }
        r0 = r3.k(r0, r2);	 Catch:{ SQLiteException -> 0x00f1 }
        if (r0 == 0) goto L_0x00f5;
    L_0x00e9:
        r0 = r10.n;	 Catch:{ SQLiteException -> 0x00f1 }
        r2 = r10.o;	 Catch:{ SQLiteException -> 0x00f1 }
        r0.a(r2);	 Catch:{ SQLiteException -> 0x00f1 }
        goto L_0x00f5;
    L_0x00f1:
        r0 = move-exception;
        r0.printStackTrace();
    L_0x00f5:
        throw r1;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.b.m.c.G():void");
    }

    public final void H() {
        boolean L;
        int i = 0;
        Object obj = (this.m == i.RUN_STATUS_PAUSE || this.m == i.RUN_STATUS_CANCELED) ? null : 1;
        Object obj2;
        try {
            L = L();
            obj2 = null;
        } catch (Exception e) {
            if (e instanceof com.ss.android.socialbase.downloader.e.a) {
                this.u.d((com.ss.android.socialbase.downloader.e.a) e);
            } else {
                this.u.d(new com.ss.android.socialbase.downloader.e.a(1046, e));
            }
            L = true;
            obj2 = 1;
        }
        if (L || obj2 != null) {
            this.l.set(false);
            if (obj != null) {
                try {
                    c.j.a.d.b.j.c B = c.j.a.d.b.e.b.B();
                    if (B != null) {
                        B.i(this);
                        return;
                    }
                    return;
                } catch (Throwable th) {
                    th.printStackTrace();
                    q qVar = this.b.l;
                    com.ss.android.socialbase.downloader.g.c cVar = this.o;
                    com.ss.android.socialbase.downloader.e.a aVar = new com.ss.android.socialbase.downloader.e.a(1014, c.j.a.d.b.n.a.B(th, "removeDownloadRunnable"));
                    com.ss.android.socialbase.downloader.g.c cVar2 = this.o;
                    if (cVar2 != null) {
                        i = cVar2.o0();
                    }
                    c.j.a.c.y.a.i.n(qVar, cVar, aVar, i);
                    return;
                }
            }
            return;
        }
        this.C = true;
        c.j.a.d.b.g.a.d(I, "jump to restart");
    }

    public final void I() {
        c.j.a.d.b.i.f fVar = this.y;
        if (fVar != null) {
            fVar.c();
            this.y = null;
        }
        c.j.a.d.b.i.h hVar = this.x;
        if (hVar != null) {
            hVar.d();
            this.x = null;
        }
    }

    public final boolean J() {
        return this.m == i.RUN_STATUS_CANCELED || this.m == i.RUN_STATUS_PAUSE;
    }

    public final boolean K() {
        if (!J() && this.o.o0() != -2) {
            return false;
        }
        if (!J()) {
            if (this.o.o0() == -2) {
                this.m = i.RUN_STATUS_PAUSE;
            } else if (this.o.o0() == -4) {
                this.m = i.RUN_STATUS_CANCELED;
            }
        }
        return true;
    }

    /* JADX WARNING: Removed duplicated region for block: B:59:0x00f1  */
    /* JADX WARNING: Removed duplicated region for block: B:59:0x00f1  */
    /* JADX WARNING: Removed duplicated region for block: B:73:0x0179  */
    /* JADX WARNING: Removed duplicated region for block: B:73:0x0179  */
    /* JADX WARNING: Missing block: B:44:0x00bd, code skipped:
            if (r1.o.I() == r1.o.T) goto L_0x00ec;
     */
    public final boolean L() {
        /*
        r16 = this;
        r1 = r16;
        r2 = c.j.a.d.b.b.i.RUN_STATUS_RETRY_DELAY;
        r0 = c.j.a.d.b.i.c.a();
        java.util.Objects.requireNonNull(r0);
        r3 = 1;
        r4 = r0.b;	 Catch:{ all -> 0x002e }
        r4 = r4.decrementAndGet();	 Catch:{ all -> 0x002e }
        if (r4 != 0) goto L_0x002f;
    L_0x0014:
        r4 = c.j.a.d.b.g.a.b();	 Catch:{ all -> 0x002e }
        if (r4 == 0) goto L_0x0021;
    L_0x001a:
        r4 = c.j.a.d.b.i.c.e;	 Catch:{ all -> 0x002e }
        r5 = "stopSampling";
        c.j.a.d.b.g.a.d(r4, r5);	 Catch:{ all -> 0x002e }
    L_0x0021:
        r4 = r0.c;	 Catch:{ all -> 0x002e }
        r4.removeMessages(r3);	 Catch:{ all -> 0x002e }
        r0.b();	 Catch:{ all -> 0x002e }
        r4 = -1;
        c.j.a.d.b.i.c.f = r4;	 Catch:{ all -> 0x002e }
        goto L_0x002f;
    L_0x002f:
        r0 = r1.m;
        r4 = c.j.a.d.b.b.i.RUN_STATUS_ERROR;
        if (r0 != r4) goto L_0x003e;
    L_0x0035:
        r0 = r1.u;
        r2 = r1.w;
        r0.d(r2);
        goto L_0x01ba;
    L_0x003e:
        r0 = r1.m;
        r4 = c.j.a.d.b.b.i.RUN_STATUS_CANCELED;
        if (r0 != r4) goto L_0x004d;
    L_0x0044:
        r0 = r1.u;
        r2 = -4;
        r4 = 0;
        r0.b(r2, r4, r3);
        goto L_0x01ba;
    L_0x004d:
        r0 = r1.m;
        r4 = c.j.a.d.b.b.i.RUN_STATUS_PAUSE;
        if (r0 != r4) goto L_0x005a;
    L_0x0053:
        r0 = r1.u;
        r0.i();
        goto L_0x01ba;
    L_0x005a:
        r0 = r1.m;
        r4 = c.j.a.d.b.b.i.RUN_STATUS_END_RIGHT_NOW;
        if (r0 != r4) goto L_0x006f;
    L_0x0060:
        r0 = r1.u;	 Catch:{ a -> 0x0067 }
        r0.l();	 Catch:{ a -> 0x0067 }
        goto L_0x01ba;
    L_0x0067:
        r0 = move-exception;
        r2 = r1.u;
        r2.d(r0);
        goto L_0x01ba;
    L_0x006f:
        r0 = r1.m;
        r4 = c.j.a.d.b.b.i.RUN_STATUS_END_FOR_FILE_EXIST;
        if (r0 != r4) goto L_0x0086;
    L_0x0075:
        r0 = r1.u;	 Catch:{ a -> 0x007e }
        r2 = r1.E;	 Catch:{ a -> 0x007e }
        r0.f(r2);	 Catch:{ a -> 0x007e }
        goto L_0x01ba;
    L_0x007e:
        r0 = move-exception;
        r2 = r1.u;
        r2.d(r0);
        goto L_0x01ba;
    L_0x0086:
        r0 = r1.m;
        r4 = c.j.a.d.b.b.i.RUN_STATUS_ALL_CHUNK_RETRY_WITH_RESET;
        r5 = 0;
        if (r0 != r4) goto L_0x0095;
    L_0x008d:
        r0 = r1.u;
        r2 = r1.w;
        r0.e(r2, r5);
        return r5;
    L_0x0095:
        r0 = r1.m;
        r4 = c.j.a.d.b.b.i.RUN_STATUS_WAITING_ASYNC_HANDLER;
        if (r0 != r4) goto L_0x009c;
    L_0x009b:
        return r3;
    L_0x009c:
        r0 = r1.m;
        r4 = 2;
        if (r0 != r2) goto L_0x0195;
    L_0x00a1:
        r0 = r1.o;
        r6 = r0.R;
        if (r6 > r3) goto L_0x00c0;
    L_0x00a7:
        r6 = r0.I();
        r8 = 0;
        r0 = (r6 > r8 ? 1 : (r6 == r8 ? 0 : -1));
        if (r0 <= 0) goto L_0x00ee;
    L_0x00b1:
        r0 = r1.o;
        r6 = r0.I();
        r0 = r1.o;
        r8 = r0.T;
        r0 = (r6 > r8 ? 1 : (r6 == r8 ? 0 : -1));
        if (r0 != 0) goto L_0x00ee;
    L_0x00bf:
        goto L_0x00ec;
    L_0x00c0:
        r6 = r1.n;
        r0 = r0.g0();
        r0 = r6.c(r0);
        if (r0 == 0) goto L_0x00ee;
    L_0x00cc:
        r6 = r0.size();
        if (r6 > r3) goto L_0x00d3;
    L_0x00d2:
        goto L_0x00ee;
    L_0x00d3:
        r0 = r0.iterator();
    L_0x00d7:
        r6 = r0.hasNext();
        if (r6 == 0) goto L_0x00ec;
    L_0x00dd:
        r6 = r0.next();
        r6 = (com.ss.android.socialbase.downloader.g.b) r6;
        if (r6 == 0) goto L_0x00ee;
    L_0x00e5:
        r6 = r6.m();
        if (r6 != 0) goto L_0x00d7;
    L_0x00eb:
        goto L_0x00ee;
    L_0x00ec:
        r0 = 1;
        goto L_0x00ef;
    L_0x00ee:
        r0 = 0;
    L_0x00ef:
        if (r0 != 0) goto L_0x0195;
    L_0x00f1:
        r0 = I;
        r6 = "doTaskStatusHandle retryDelay";
        c.j.a.d.b.g.a.d(r0, r6);
        r6 = "extra_download_id";
        r7 = "com.ss.android.downloader.action.DOWNLOAD_WAKEUP";
        r8 = c.j.a.d.b.b.h.DELAY_RETRY_WAITING;
        r9 = r16.N();
        r11 = 1073741824; // 0x40000000 float:2.0 double:5.304989477E-315;
        r0 = new android.content.Intent;	 Catch:{ all -> 0x0134 }
        r0.<init>(r7);	 Catch:{ all -> 0x0134 }
        r12 = r1.o;	 Catch:{ all -> 0x0134 }
        r12 = r12.g0();	 Catch:{ all -> 0x0134 }
        r0.putExtra(r6, r12);	 Catch:{ all -> 0x0134 }
        r12 = c.j.a.d.b.e.b.a();	 Catch:{ all -> 0x0134 }
        r13 = com.ss.android.socialbase.downloader.impls.DownloadHandleService.class;
        r0.setClass(r12, r13);	 Catch:{ all -> 0x0134 }
        r12 = r1.v;	 Catch:{ all -> 0x0134 }
        r13 = android.os.SystemClock.elapsedRealtime();	 Catch:{ all -> 0x0134 }
        r13 = r13 + r9;
        r15 = c.j.a.d.b.e.b.a();	 Catch:{ all -> 0x0134 }
        r3 = r1.o;	 Catch:{ all -> 0x0134 }
        r3 = r3.g0();	 Catch:{ all -> 0x0134 }
        r0 = android.app.PendingIntent.getService(r15, r3, r0, r11);	 Catch:{ all -> 0x0134 }
        r12.setExact(r4, r13, r0);	 Catch:{ all -> 0x0134 }
        goto L_0x016d;
    L_0x0134:
        r0 = move-exception;
        r0 = r0 instanceof java.lang.NoSuchMethodError;	 Catch:{ all -> 0x0185 }
        if (r0 == 0) goto L_0x016a;
    L_0x0139:
        r0 = new android.content.Intent;	 Catch:{ all -> 0x016a }
        r0.<init>(r7);	 Catch:{ all -> 0x016a }
        r3 = c.j.a.d.b.e.b.a();	 Catch:{ all -> 0x016a }
        r7 = com.ss.android.socialbase.downloader.impls.DownloadHandleService.class;
        r0.setClass(r3, r7);	 Catch:{ all -> 0x016a }
        r3 = r1.o;	 Catch:{ all -> 0x016a }
        r3 = r3.g0();	 Catch:{ all -> 0x016a }
        r0.putExtra(r6, r3);	 Catch:{ all -> 0x016a }
        r3 = r1.v;	 Catch:{ all -> 0x016a }
        r6 = android.os.SystemClock.elapsedRealtime();	 Catch:{ all -> 0x016a }
        r6 = r6 + r9;
        r9 = c.j.a.d.b.e.b.a();	 Catch:{ all -> 0x016a }
        r10 = r1.o;	 Catch:{ all -> 0x016a }
        r10 = r10.g0();	 Catch:{ all -> 0x016a }
        r0 = android.app.PendingIntent.getService(r9, r10, r0, r11);	 Catch:{ all -> 0x016a }
        r3.set(r4, r6, r0);	 Catch:{ all -> 0x016a }
        r0 = 1;
        goto L_0x016b;
    L_0x016a:
        r0 = 0;
    L_0x016b:
        if (r0 == 0) goto L_0x0179;
    L_0x016d:
        r1.m = r2;
        r0 = r1.o;
        r0.G = r8;
        r3 = r1.n;
        r3.a(r0);
        goto L_0x017d;
    L_0x0179:
        r0 = c.j.a.d.b.b.i.RUN_STATUS_NONE;
        r1.m = r0;
    L_0x017d:
        r0 = r1.m;
        if (r0 != r2) goto L_0x0183;
    L_0x0181:
        r3 = 1;
        goto L_0x0184;
    L_0x0183:
        r3 = 0;
    L_0x0184:
        return r3;
    L_0x0185:
        r0 = move-exception;
        r3 = r0;
        r1.m = r2;
        r0 = r1.o;
        r0.G = r8;
        r0 = r1.n;
        r2 = r1.o;
        r0.a(r2);
        throw r3;
    L_0x0195:
        r0 = r16.M();	 Catch:{ all -> 0x01a9 }
        if (r0 != 0) goto L_0x019c;
    L_0x019b:
        return r5;
    L_0x019c:
        r0 = r1.u;	 Catch:{ all -> 0x01a9 }
        r0.k();	 Catch:{ all -> 0x01a9 }
        r0 = c.j.a.d.b.j.a0.a();	 Catch:{ all -> 0x01a9 }
        r0.b(r4, r5);	 Catch:{ all -> 0x01a9 }
        goto L_0x01ba;
    L_0x01a9:
        r0 = move-exception;
        r2 = new com.ss.android.socialbase.downloader.e.a;
        r3 = 1008; // 0x3f0 float:1.413E-42 double:4.98E-321;
        r4 = "doTaskStatusHandle onComplete";
        r0 = c.j.a.d.b.n.a.B(r0, r4);
        r2.m4677init(r3, r0);
        r1.B(r2);
    L_0x01ba:
        r2 = 1;
        return r2;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.b.m.c.L():boolean");
    }

    public final boolean M() {
        com.ss.android.socialbase.downloader.g.c cVar;
        if (c.j.a.d.b.n.a.F(this.o.T)) {
            cVar = this.o;
            cVar.T = cVar.I();
        }
        if (this.o.I() > 0) {
            Objects.requireNonNull(this.o);
            cVar = this.o;
            if (cVar.T > 0 && cVar.I() == this.o.T) {
                return true;
            }
        }
        cVar = this.o;
        cVar.k0 = c.j.a.d.b.b.b.BYTE_INVALID_RETRY_STATUS_RESTART;
        cVar.P();
        this.n.a(this.o);
        this.n.d(this.o.g0());
        c.j.a.d.b.n.a.n(this.o, true);
        return false;
    }

    public final long N() {
        return this.t.a(this.o.e(), this.o.d());
    }

    /* JADX WARNING: Removed duplicated region for block: B:44:? A:{SYNTHETIC, RETURN} */
    /* JADX WARNING: Removed duplicated region for block: B:21:0x004c  */
    public final void O() throws c.j.a.d.b.m.c.c, com.ss.android.socialbase.downloader.e.a {
        /*
        r9 = this;
        r0 = r9.o;
        r0 = r0.g0();
        r1 = r9.o;
        r1 = c.j.a.d.b.e.b.b(r1);
        r2 = r9.o;
        r2 = r2.F();
        if (r2 != 0) goto L_0x00b2;
    L_0x0014:
        r2 = r9.n;
        r2 = r2.b(r1);
        if (r2 == 0) goto L_0x00b1;
    L_0x001c:
        r3 = c.j.a.d.b.e.b.B();
        if (r3 == 0) goto L_0x00b1;
    L_0x0022:
        r4 = r2.g0();
        if (r4 == r0) goto L_0x00b1;
    L_0x0028:
        r4 = r9.o;
        r5 = 1;
        r6 = 0;
        if (r4 != 0) goto L_0x002f;
    L_0x002e:
        goto L_0x0049;
    L_0x002f:
        r7 = r2.d;
        if (r7 == 0) goto L_0x0049;
    L_0x0033:
        r8 = r4.d;
        r7 = r7.equals(r8);
        if (r7 == 0) goto L_0x0049;
    L_0x003b:
        r7 = r2.e;
        if (r7 == 0) goto L_0x0049;
    L_0x003f:
        r4 = r4.e;
        r4 = r7.equals(r4);
        if (r4 == 0) goto L_0x0049;
    L_0x0047:
        r4 = 1;
        goto L_0x004a;
    L_0x0049:
        r4 = 0;
    L_0x004a:
        if (r4 == 0) goto L_0x00b1;
    L_0x004c:
        r4 = r2.g0();
        r3 = r3.j(r4);
        if (r3 != 0) goto L_0x00a2;
    L_0x0056:
        r3 = r9.n;
        r3 = r3.c(r1);
        r4 = r9.o;
        c.j.a.d.b.n.a.n(r4, r5);
        r4 = r9.n;
        r4.f(r1);
        r1 = r2.R();
        if (r1 != 0) goto L_0x006e;
    L_0x006c:
        r1 = 0;
        goto L_0x0072;
    L_0x006e:
        r1 = r2.S();
    L_0x0072:
        if (r1 == 0) goto L_0x00b1;
    L_0x0074:
        r1 = r9.o;
        r1.s(r2, r6);
        r1 = r9.n;
        r2 = r9.o;
        r1.a(r2);
        if (r3 == 0) goto L_0x009a;
    L_0x0082:
        r1 = r3.iterator();
    L_0x0086:
        r2 = r1.hasNext();
        if (r2 == 0) goto L_0x009a;
    L_0x008c:
        r2 = r1.next();
        r2 = (com.ss.android.socialbase.downloader.g.b) r2;
        r2.a = r0;
        r3 = r9.n;
        r3.f(r2);
        goto L_0x0086;
    L_0x009a:
        r0 = new c.j.a.d.b.m.c$c;
        r1 = "retry task because id generator changed";
        r0.m2458init(r9, r1);
        throw r0;
    L_0x00a2:
        r1 = r9.n;
        r1.f(r0);
        r0 = new com.ss.android.socialbase.downloader.e.a;
        r1 = 1025; // 0x401 float:1.436E-42 double:5.064E-321;
        r2 = "another same task is downloading";
        r0.m4677init(r1, r2);
        throw r0;
    L_0x00b1:
        return;
    L_0x00b2:
        r0 = new com.ss.android.socialbase.downloader.e.a;
        r1 = 1009; // 0x3f1 float:1.414E-42 double:4.985E-321;
        r2 = "file has downloaded";
        r0.m4677init(r1, r2);
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.b.m.c.O():void");
    }

    public final void a() throws com.ss.android.socialbase.downloader.e.g {
        if (this.o.g) {
            if (!c.j.a.d.b.n.a.u(c.j.a.d.b.e.b.a(), "android.permission.ACCESS_NETWORK_STATE")) {
                throw new com.ss.android.socialbase.downloader.e.g(1019, String.format("download task need permission:%s", new Object[]{"android.permission.ACCESS_NETWORK_STATE"}));
            }
        }
        if (!this.o.B()) {
            throw new d();
        } else if (!this.o.C()) {
            throw new com.ss.android.socialbase.downloader.e.f();
        }
    }

    public final void b() throws com.ss.android.socialbase.downloader.e.a {
        if (TextUtils.isEmpty(this.o.e)) {
            throw new com.ss.android.socialbase.downloader.e.a(1028, "download savePath can not be empty");
        } else if (TextUtils.isEmpty(this.o.b)) {
            throw new com.ss.android.socialbase.downloader.e.a(1029, "download name can not be empty");
        } else {
            File file = new File(this.o.e);
            if (file.exists()) {
                if (!file.isDirectory()) {
                    throw new com.ss.android.socialbase.downloader.e.a(1031, "download savePath is not a directory");
                }
            } else if (!file.mkdirs()) {
                throw new com.ss.android.socialbase.downloader.e.a(1030, "download savePath directory can not created");
            }
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:20:0x004a  */
    /* JADX WARNING: Removed duplicated region for block: B:25:? A:{SYNTHETIC, RETURN} */
    /* JADX WARNING: Removed duplicated region for block: B:23:0x004f  */
    public final void c() {
        /*
        r9 = this;
        r0 = r9.o;
        r1 = c.j.a.d.b.n.a.a;
        r1 = 0;
        r3 = 1;
        r4 = 0;
        if (r0 != 0) goto L_0x000b;
    L_0x000a:
        goto L_0x0040;
    L_0x000b:
        r5 = c.j.a.d.b.e.b.x();
        r6 = r0.g0();
        r5 = r5.c(r6);
        r6 = r0.R;
        if (r6 <= r3) goto L_0x001d;
    L_0x001b:
        r7 = 1;
        goto L_0x001e;
    L_0x001d:
        r7 = 0;
    L_0x001e:
        r8 = r0.R();
        if (r8 != 0) goto L_0x0026;
    L_0x0024:
        r8 = 0;
        goto L_0x002a;
    L_0x0026:
        r8 = r0.S();
    L_0x002a:
        if (r8 == 0) goto L_0x0040;
    L_0x002c:
        if (r7 == 0) goto L_0x003b;
    L_0x002e:
        if (r5 == 0) goto L_0x0040;
    L_0x0030:
        r0 = r5.size();
        if (r6 != r0) goto L_0x0040;
    L_0x0036:
        r5 = c.j.a.d.b.n.a.y(r5);
        goto L_0x0041;
    L_0x003b:
        r5 = r0.I();
        goto L_0x0041;
    L_0x0040:
        r5 = r1;
    L_0x0041:
        r0 = r9.o;
        r0.d0(r5);
        r0 = (r5 > r1 ? 1 : (r5 == r1 ? 0 : -1));
        if (r0 <= 0) goto L_0x004b;
    L_0x004a:
        r4 = 1;
    L_0x004b:
        r9.h = r4;
        if (r4 != 0) goto L_0x005f;
    L_0x004f:
        r0 = r9.n;
        r1 = r9.o;
        r1 = r1.g0();
        r0.d(r1);
        r0 = r9.o;
        c.j.a.d.b.n.a.n(r0, r3);
    L_0x005f:
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.b.m.c.c():void");
    }

    public final void d() {
        try {
            this.n.d(this.o.g0());
            c.j.a.d.b.n.a.n(this.o, true);
            this.h = false;
            com.ss.android.socialbase.downloader.g.c cVar = this.o;
            cVar.p(0, true);
            cVar.T = 0;
            cVar.E = "";
            cVar.R = 1;
            cVar.X = 0;
            cVar.d0 = 0;
            cVar.Y = 0;
            this.n.a(this.o);
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    public final void e() {
        try {
            Iterator it = ((ArrayList) this.e.clone()).iterator();
            while (it.hasNext()) {
                b bVar = (b) it.next();
                if (bVar != null) {
                    bVar.d();
                }
            }
        } catch (Throwable th) {
            String str = I;
            StringBuilder g = c.b.a.a.a.g("cancelAllChunkRunnable: ");
            g.append(th.toString());
            c.j.a.d.b.g.a.e(str, g.toString());
        }
    }

    /* JADX WARNING: Missing block: B:28:0x006d, code skipped:
            if (r9 <= 0) goto L_0x006f;
     */
    public final int f(long r7, java.util.List<com.ss.android.socialbase.downloader.g.b> r9) {
        /*
        r6 = this;
        r0 = I;
        r1 = r6.o;
        r2 = 0;
        r3 = 1;
        if (r1 == 0) goto L_0x001f;
    L_0x0008:
        r4 = r6.h;
        if (r4 == 0) goto L_0x0010;
    L_0x000c:
        r4 = r1.R;
        if (r4 <= r3) goto L_0x001f;
    L_0x0010:
        r4 = r1.y0;
        if (r4 == 0) goto L_0x0015;
    L_0x0014:
        goto L_0x001f;
    L_0x0015:
        r4 = r6.i;
        if (r4 == 0) goto L_0x001f;
    L_0x0019:
        r4 = r6.k;
        if (r4 != 0) goto L_0x001f;
    L_0x001d:
        r4 = 1;
        goto L_0x0020;
    L_0x001f:
        r4 = 0;
    L_0x0020:
        if (r4 == 0) goto L_0x006f;
    L_0x0022:
        r4 = r6.h;
        if (r4 == 0) goto L_0x0030;
    L_0x0026:
        if (r9 == 0) goto L_0x002d;
    L_0x0028:
        r9 = r9.size();
        goto L_0x006d;
    L_0x002d:
        r9 = r1.R;
        goto L_0x006d;
    L_0x0030:
        r9 = r6.p;
        if (r9 == 0) goto L_0x0039;
    L_0x0034:
        r9 = r9.a(r7);
        goto L_0x003f;
    L_0x0039:
        r9 = r6.q;
        r9 = r9.a(r7);
    L_0x003f:
        r1 = c.j.a.d.b.i.k.b.a;
        r1 = r1.b();
        r4 = new java.lang.Object[r3];
        r5 = r1.name();
        r4[r2] = r5;
        r5 = "NetworkQuality is : %s";
        r4 = java.lang.String.format(r5, r4);
        c.j.a.d.b.g.a.d(r0, r4);
        r4 = r6.o;
        r5 = r1.name();
        r4.O = r5;
        r4 = r6.r;
        if (r4 == 0) goto L_0x0067;
    L_0x0062:
        r9 = r4.a(r9, r1);
        goto L_0x006d;
    L_0x0067:
        r4 = r6.s;
        r9 = r4.a(r9, r1);
    L_0x006d:
        if (r9 > 0) goto L_0x0070;
    L_0x006f:
        r9 = 1;
    L_0x0070:
        r1 = c.j.a.d.b.g.a.b();
        if (r1 == 0) goto L_0x0095;
    L_0x0076:
        r1 = 3;
        r1 = new java.lang.Object[r1];
        r4 = java.lang.String.valueOf(r9);
        r1[r2] = r4;
        r2 = r6.o;
        r2 = r2.b;
        r1[r3] = r2;
        r2 = 2;
        r7 = java.lang.String.valueOf(r7);
        r1[r2] = r7;
        r7 = "chunk count : %s for %s contentLen:%s";
        r7 = java.lang.String.format(r7, r1);
        c.j.a.d.b.g.a.d(r0, r7);
    L_0x0095:
        return r9;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.b.m.c.f(long, java.util.List):int");
    }

    /* JADX WARNING: Removed duplicated region for block: B:64:0x00da  */
    /* JADX WARNING: Removed duplicated region for block: B:78:0x0103  */
    /* JADX WARNING: Removed duplicated region for block: B:81:0x010c  */
    /* JADX WARNING: Removed duplicated region for block: B:64:0x00da  */
    /* JADX WARNING: Removed duplicated region for block: B:78:0x0103  */
    /* JADX WARNING: Removed duplicated region for block: B:81:0x010c  */
    /* JADX WARNING: Removed duplicated region for block: B:64:0x00da  */
    /* JADX WARNING: Removed duplicated region for block: B:78:0x0103  */
    /* JADX WARNING: Removed duplicated region for block: B:81:0x010c  */
    /* JADX WARNING: Missing block: B:42:0x00b7, code skipped:
            return r2;
     */
    /* JADX WARNING: Missing block: B:45:0x00bd, code skipped:
            if (D(r12) == false) goto L_0x00c0;
     */
    /* JADX WARNING: Missing block: B:46:0x00bf, code skipped:
            return r2;
     */
    public c.j.a.d.b.f.a g(com.ss.android.socialbase.downloader.e.a r12, long r13) {
        /*
        r11 = this;
        r0 = c.j.a.d.b.b.i.RUN_STATUS_RETRY_DELAY;
        r1 = c.j.a.d.b.b.i.RUN_STATUS_WAITING_ASYNC_HANDLER;
        r2 = c.j.a.d.b.f.a.RETURN;
        r11.w = r12;
        r3 = r11.o;
        r13 = -r13;
        r3 = r3.S;
        r3.addAndGet(r13);
        r13 = r11.n;
        r14 = r11.o;
        r13.a(r14);
        r13 = r11.J();
        if (r13 == 0) goto L_0x001e;
    L_0x001d:
        return r2;
    L_0x001e:
        r13 = r12.a;
        r14 = 1047; // 0x417 float:1.467E-42 double:5.173E-321;
        r3 = 1;
        r4 = 0;
        if (r13 != r14) goto L_0x0058;
    L_0x0026:
        r13 = r11.z;
        if (r13 == 0) goto L_0x0051;
    L_0x002a:
        r14 = r11.o;
        r14 = r14.s0;
        if (r14 == 0) goto L_0x0031;
    L_0x0030:
        goto L_0x0051;
    L_0x0031:
        r14 = new c.j.a.d.b.m.c$a;
        r14.m8080init();
        r13 = (c.j.a.d.b.n.g) r13;
        r13 = r13.a(r14);
        r5 = r11.o;
        r5.s0 = r3;
        if (r13 == 0) goto L_0x00d7;
    L_0x0042:
        r13 = r14.a;
        if (r13 != 0) goto L_0x00c0;
    L_0x0046:
        r11.e();
        r12 = r11.u;
        r12.m();
        r11.m = r1;
        return r2;
    L_0x0051:
        r13 = r11.D(r12);
        if (r13 == 0) goto L_0x00d7;
    L_0x0057:
        return r2;
    L_0x0058:
        r13 = c.j.a.d.b.n.a.W(r12);
        if (r13 == 0) goto L_0x00d0;
    L_0x005e:
        r13 = r11.A;
        if (r13 != 0) goto L_0x0066;
    L_0x0062:
        r11.B(r12);
        return r2;
    L_0x0066:
        r13 = new java.util.concurrent.atomic.AtomicBoolean;
        r13.<init>(r4);
        r10 = new c.j.a.d.b.m.c$b;
        r10.m6458init(r13);
        r14 = r12 instanceof com.ss.android.socialbase.downloader.e.e;
        if (r14 == 0) goto L_0x007c;
    L_0x0074:
        r14 = r12;
        r14 = (com.ss.android.socialbase.downloader.e.e) r14;
        r5 = r14.c;
        r7 = r14.d;
        goto L_0x0082;
    L_0x007c:
        r5 = -1;
        r14 = r11.o;
        r7 = r14.T;
    L_0x0082:
        r8 = r7;
        r6 = r5;
        monitor-enter(r11);
        r5 = r11.A;	 Catch:{ all -> 0x00cd }
        r14 = r5.a(r6, r8, r10);	 Catch:{ all -> 0x00cd }
        if (r14 == 0) goto L_0x00c2;
    L_0x008d:
        r14 = r11.o;	 Catch:{ all -> 0x00cd }
        r14 = r14.g0();	 Catch:{ all -> 0x00cd }
        r14 = c.j.a.d.b.l.a.d(r14);	 Catch:{ all -> 0x00cd }
        r5 = "not_delete_when_clean_space";
        r14 = r14.k(r5, r4);	 Catch:{ all -> 0x00cd }
        if (r14 != 0) goto L_0x00a2;
    L_0x009f:
        r11.M();	 Catch:{ all -> 0x00cd }
    L_0x00a2:
        r13 = r13.get();	 Catch:{ all -> 0x00cd }
        if (r13 != 0) goto L_0x00b8;
    L_0x00a8:
        r12 = r11.m;	 Catch:{ all -> 0x00cd }
        if (r12 == r1) goto L_0x00b6;
    L_0x00ac:
        r11.m = r1;	 Catch:{ all -> 0x00cd }
        r11.e();	 Catch:{ all -> 0x00cd }
        r12 = r11.u;	 Catch:{ all -> 0x00cd }
        r12.m();	 Catch:{ all -> 0x00cd }
    L_0x00b6:
        monitor-exit(r11);	 Catch:{ all -> 0x00cd }
        return r2;
    L_0x00b8:
        monitor-exit(r11);	 Catch:{ all -> 0x00cd }
        r13 = r11.D(r12);
        if (r13 == 0) goto L_0x00c0;
    L_0x00bf:
        return r2;
    L_0x00c0:
        r13 = 1;
        goto L_0x00d8;
    L_0x00c2:
        r13 = r11.m;	 Catch:{ all -> 0x00cd }
        if (r13 != r1) goto L_0x00c8;
    L_0x00c6:
        monitor-exit(r11);	 Catch:{ all -> 0x00cd }
        return r2;
    L_0x00c8:
        r11.B(r12);	 Catch:{ all -> 0x00cd }
        monitor-exit(r11);	 Catch:{ all -> 0x00cd }
        return r2;
    L_0x00cd:
        r12 = move-exception;
        monitor-exit(r11);	 Catch:{ all -> 0x00cd }
        throw r12;
    L_0x00d0:
        r13 = r11.D(r12);
        if (r13 == 0) goto L_0x00d7;
    L_0x00d6:
        return r2;
    L_0x00d7:
        r13 = 0;
    L_0x00d8:
        if (r13 != 0) goto L_0x00fc;
    L_0x00da:
        r13 = r11.m;
        if (r13 == r0) goto L_0x00f6;
    L_0x00de:
        r13 = r11.v;
        if (r13 == 0) goto L_0x00f6;
    L_0x00e2:
        r13 = r11.o;
        r13 = r13.A;
        if (r13 == 0) goto L_0x00f6;
    L_0x00e8:
        r13 = r11.N();
        r5 = 0;
        r1 = (r13 > r5 ? 1 : (r13 == r5 ? 0 : -1));
        if (r1 <= 0) goto L_0x00f6;
    L_0x00f2:
        r11.m = r0;
        r13 = 1;
        goto L_0x00f7;
    L_0x00f6:
        r13 = 0;
    L_0x00f7:
        if (r13 == 0) goto L_0x00fc;
    L_0x00f9:
        r11.e();
    L_0x00fc:
        r13 = r11.u;
        r14 = r11.m;
        if (r14 != r0) goto L_0x0103;
    L_0x0102:
        goto L_0x0104;
    L_0x0103:
        r3 = 0;
    L_0x0104:
        r13.e(r12, r3);
        r12 = r11.m;
        if (r12 != r0) goto L_0x010c;
    L_0x010b:
        goto L_0x010e;
    L_0x010c:
        r2 = c.j.a.d.b.f.a.CONTINUE;
    L_0x010e:
        return r2;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.b.m.c.g(com.ss.android.socialbase.downloader.e.a, long):c.j.a.d.b.f.a");
    }

    public c.j.a.d.b.f.a h(com.ss.android.socialbase.downloader.g.b bVar, com.ss.android.socialbase.downloader.e.a aVar, long j) {
        String str = I;
        c.j.a.d.b.f.a aVar2 = c.j.a.d.b.f.a.RETURN;
        if (J()) {
            return aVar2;
        }
        if (aVar.a == 1047 || c.j.a.d.b.n.a.W(aVar)) {
            return g(aVar, j);
        }
        this.w = aVar;
        this.o.S.addAndGet(-j);
        this.n.a(this.o);
        if (D(aVar)) {
            return aVar2;
        }
        h hVar = this.u;
        i iVar = this.m;
        i iVar2 = i.RUN_STATUS_RETRY_DELAY;
        Object obj = iVar == iVar2 ? 1 : null;
        hVar.b.V = false;
        hVar.k.set(0);
        hVar.c.g(hVar.b.g0());
        hVar.b(obj != null ? 10 : 9, aVar, true);
        if (this.m != iVar2 && this.o.A) {
            long N = N();
            if (N > 0) {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.append("onSingleChunkRetry with delay time ");
                stringBuilder.append(N);
                c.j.a.d.b.g.a.e(str, stringBuilder.toString());
                try {
                    Thread.sleep(N);
                } catch (Throwable th) {
                    StringBuilder g = c.b.a.a.a.g("onSingleChunkRetry:");
                    g.append(th.getMessage());
                    c.j.a.d.b.g.a.f(str, g.toString());
                }
            }
        }
        return c.j.a.d.b.f.a.CONTINUE;
    }

    /* JADX WARNING: Missing block: B:27:0x003c, code skipped:
            return null;
     */
    public synchronized com.ss.android.socialbase.downloader.g.b i(int r5) {
        /*
        r4 = this;
        monitor-enter(r4);
        r0 = r4.o;	 Catch:{ all -> 0x003d }
        r1 = r0.R;	 Catch:{ all -> 0x003d }
        r2 = 2;
        r3 = 0;
        if (r1 >= r2) goto L_0x000b;
    L_0x0009:
        monitor-exit(r4);
        return r3;
    L_0x000b:
        r1 = r4.n;	 Catch:{ all -> 0x003d }
        r0 = r0.g0();	 Catch:{ all -> 0x003d }
        r0 = r1.c(r0);	 Catch:{ all -> 0x003d }
        if (r0 == 0) goto L_0x003b;
    L_0x0017:
        r1 = r0.isEmpty();	 Catch:{ all -> 0x003d }
        if (r1 == 0) goto L_0x001e;
    L_0x001d:
        goto L_0x003b;
    L_0x001e:
        r1 = 0;
    L_0x001f:
        r2 = r0.size();	 Catch:{ all -> 0x003d }
        if (r1 >= r2) goto L_0x0039;
    L_0x0025:
        r2 = r0.get(r1);	 Catch:{ all -> 0x003d }
        r2 = (com.ss.android.socialbase.downloader.g.b) r2;	 Catch:{ all -> 0x003d }
        if (r2 != 0) goto L_0x002e;
    L_0x002d:
        goto L_0x0036;
    L_0x002e:
        r2 = r4.j(r2, r5);	 Catch:{ all -> 0x003d }
        if (r2 == 0) goto L_0x0036;
    L_0x0034:
        monitor-exit(r4);
        return r2;
    L_0x0036:
        r1 = r1 + 1;
        goto L_0x001f;
    L_0x0039:
        monitor-exit(r4);
        return r3;
    L_0x003b:
        monitor-exit(r4);
        return r3;
    L_0x003d:
        r5 = move-exception;
        monitor-exit(r4);
        throw r5;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.b.m.c.i(int):com.ss.android.socialbase.downloader.g.b");
    }

    /* JADX WARNING: Removed duplicated region for block: B:58:0x01ea  */
    public final com.ss.android.socialbase.downloader.g.b j(com.ss.android.socialbase.downloader.g.b r30, int r31) {
        /*
        r29 = this;
        r0 = r29;
        r1 = r30;
        r2 = r31;
        r3 = I;
        r4 = r30.h();
        r5 = 0;
        if (r4 != 0) goto L_0x0010;
    L_0x000f:
        return r5;
    L_0x0010:
        r4 = 1;
        r5 = r1.g(r4);
        r7 = new java.lang.StringBuilder;
        r7.<init>();
        r8 = "reuseChunk retainLen:";
        r7.append(r8);
        r7.append(r5);
        r8 = " chunkIndex:";
        r7.append(r8);
        r7.append(r2);
        r7 = r7.toString();
        c.j.a.d.b.g.a.d(r3, r7);
        r7 = r30.j();
        r8 = " contentLen:";
        r9 = " curOffset:";
        if (r7 != 0) goto L_0x01dc;
    L_0x003b:
        r7 = c.j.a.d.b.b.e.a;
        r10 = 5242880; // 0x500000 float:7.34684E-39 double:2.590327E-317;
        r7 = (r5 > r10 ? 1 : (r5 == r10 ? 0 : -1));
        if (r7 <= 0) goto L_0x01dc;
    L_0x0044:
        r5 = r0.o;
        r6 = r5.D;
        if (r6 == 0) goto L_0x01dc;
    L_0x004a:
        r6 = r5.R;
        r10 = r5.T;
        r5 = com.ss.android.socialbase.downloader.g.b.n;
        r7 = r30.h();
        if (r7 == 0) goto L_0x01bc;
    L_0x0056:
        r7 = r30.j();
        if (r7 == 0) goto L_0x005e;
    L_0x005c:
        goto L_0x01bc;
    L_0x005e:
        r7 = new java.util.ArrayList;
        r7.<init>();
        r12 = r30.p();
        r14 = r1.g(r4);
        r16 = r12;
        r12 = (long) r6;
        r12 = r14 / r12;
        r4 = new java.lang.StringBuilder;
        r4.<init>();
        r2 = "retainLen:";
        r4.append(r2);
        r4.append(r14);
        r2 = " divideChunkForReuse chunkSize:";
        r4.append(r2);
        r4.append(r12);
        r2 = " current host downloadChunk index:";
        r4.append(r2);
        r2 = r1.f;
        r4.append(r2);
        r2 = r4.toString();
        c.j.a.d.b.g.a.d(r5, r2);
        r2 = 0;
        r27 = r16;
        r16 = r3;
        r3 = r27;
    L_0x009d:
        r17 = 1;
        if (r2 >= r6) goto L_0x0156;
    L_0x00a1:
        if (r2 != 0) goto L_0x00b5;
    L_0x00a3:
        r19 = r10;
        r10 = r1.b;
        r21 = r3 + r12;
        r21 = r21 - r17;
        r17 = r21;
        r21 = r7;
        r27 = r10;
        r11 = r6;
        r6 = r27;
        goto L_0x00eb;
    L_0x00b5:
        r19 = r10;
        r10 = r6 + -1;
        if (r2 != r10) goto L_0x00e1;
    L_0x00bb:
        r11 = r6;
        r21 = r7;
        r6 = r1.d;
        r22 = (r6 > r3 ? 1 : (r6 == r3 ? 0 : -1));
        if (r22 <= 0) goto L_0x00cf;
    L_0x00c4:
        r22 = r6 - r3;
        r22 = r22 + r17;
        r27 = r6;
        r6 = r22;
        r22 = r27;
        goto L_0x00d6;
    L_0x00cf:
        r22 = r6;
        r6 = (long) r10;
        r6 = r6 * r12;
        r6 = r14 - r6;
    L_0x00d6:
        r27 = r22;
        r22 = r11;
        r23 = r14;
        r10 = r27;
        r14 = r6;
        r6 = r3;
        goto L_0x00f2;
    L_0x00e1:
        r11 = r6;
        r21 = r7;
        r6 = r3 + r12;
        r6 = r6 - r17;
        r17 = r6;
        r6 = r3;
    L_0x00eb:
        r22 = r11;
        r23 = r14;
        r10 = r17;
        r14 = r12;
    L_0x00f2:
        r0 = new com.ss.android.socialbase.downloader.g.b$b;
        r25 = r12;
        r12 = r1.a;
        r0.m4681init(r12);
        r12 = -r2;
        r12 = r12 + -1;
        r0.f = r12;
        r0.b = r6;
        r0.c = r3;
        r0.g = r3;
        r0.d = r10;
        r0.e = r14;
        r0.h = r1;
        r0 = r0.a();
        r12 = new java.lang.StringBuilder;
        r12.<init>();
        r13 = "divide sub chunk : ";
        r12.append(r13);
        r12.append(r2);
        r13 = " startOffset:";
        r12.append(r13);
        r12.append(r6);
        r12.append(r9);
        r12.append(r3);
        r6 = " endOffset:";
        r12.append(r6);
        r12.append(r10);
        r12.append(r8);
        r12.append(r14);
        r6 = r12.toString();
        c.j.a.d.b.g.a.d(r5, r6);
        r6 = r21;
        r6.add(r0);
        r3 = r3 + r25;
        r2 = r2 + 1;
        r0 = r29;
        r7 = r6;
        r10 = r19;
        r6 = r22;
        r14 = r23;
        r12 = r25;
        goto L_0x009d;
    L_0x0156:
        r6 = r7;
        r19 = r10;
        r0 = r6.size();
        r0 = r0 + -1;
        r2 = 0;
        r10 = r2;
    L_0x0162:
        if (r0 <= 0) goto L_0x0172;
    L_0x0164:
        r4 = r6.get(r0);
        r4 = (com.ss.android.socialbase.downloader.g.b) r4;
        if (r4 == 0) goto L_0x016f;
    L_0x016c:
        r12 = r4.e;
        r10 = r10 + r12;
    L_0x016f:
        r0 = r0 + -1;
        goto L_0x0162;
    L_0x0172:
        r0 = new java.lang.StringBuilder;
        r0.<init>();
        r4 = "reuseChunkContentLen:";
        r0.append(r4);
        r0.append(r10);
        r0 = r0.toString();
        c.j.a.d.b.g.a.d(r5, r0);
        r0 = 0;
        r0 = r6.get(r0);
        r0 = (com.ss.android.socialbase.downloader.g.b) r0;
        if (r0 == 0) goto L_0x01b8;
    L_0x018f:
        r4 = r1.d;
        r7 = (r4 > r2 ? 1 : (r4 == r2 ? 0 : -1));
        if (r7 != 0) goto L_0x019a;
    L_0x0195:
        r2 = r1.b;
        r2 = r19 - r2;
        goto L_0x019f;
    L_0x019a:
        r2 = r1.b;
        r4 = r4 - r2;
        r2 = r4 + r17;
    L_0x019f:
        r2 = r2 - r10;
        r0.e = r2;
        r2 = r1.f;
        r0.f = r2;
        r2 = r1.m;
        if (r2 == 0) goto L_0x01b8;
    L_0x01aa:
        r3 = r0.d;
        r12 = r1.e;
        r12 = r12 - r10;
        r0 = r2.c;
        if (r0 != 0) goto L_0x01b4;
    L_0x01b3:
        goto L_0x01b8;
    L_0x01b4:
        r0.o = r3;
        r0.p = r12;
    L_0x01b8:
        r1.i = r6;
        r7 = r6;
        goto L_0x01bf;
    L_0x01bc:
        r16 = r3;
        r7 = 0;
    L_0x01bf:
        if (r7 == 0) goto L_0x01d9;
    L_0x01c1:
        r0 = r7.iterator();
    L_0x01c5:
        r2 = r0.hasNext();
        if (r2 == 0) goto L_0x01d9;
    L_0x01cb:
        r2 = r0.next();
        r2 = (com.ss.android.socialbase.downloader.g.b) r2;
        r3 = r29;
        r4 = r3.n;
        r4.E(r2);
        goto L_0x01c5;
    L_0x01d9:
        r3 = r29;
        goto L_0x01e5;
    L_0x01dc:
        r16 = r3;
        r3 = r0;
        r0 = r30.j();
        if (r0 == 0) goto L_0x01e7;
    L_0x01e5:
        r0 = 1;
        goto L_0x01e8;
    L_0x01e7:
        r0 = 0;
    L_0x01e8:
        if (r0 == 0) goto L_0x029c;
    L_0x01ea:
        r0 = r30.j();
        if (r0 == 0) goto L_0x029c;
    L_0x01f0:
        r0 = 1;
    L_0x01f1:
        r2 = r1.i;
        r2 = r2.size();
        if (r0 >= r2) goto L_0x0253;
    L_0x01f9:
        r2 = r1.i;
        r2 = r2.get(r0);
        r2 = (com.ss.android.socialbase.downloader.g.b) r2;
        if (r2 == 0) goto L_0x024c;
    L_0x0203:
        r4 = "check can checkUnCompletedChunk -- chunkIndex:";
        r4 = c.b.a.a.a.g(r4);
        r5 = r2.f;
        r4.append(r5);
        r5 = " currentOffset:";
        r4.append(r5);
        r5 = r2.q();
        r4.append(r5);
        r5 = "  startOffset:";
        r4.append(r5);
        r5 = r2.b;
        r4.append(r5);
        r4.append(r8);
        r5 = r2.e;
        r4.append(r5);
        r4 = r4.toString();
        r5 = r16;
        c.j.a.d.b.g.a.d(r5, r4);
        r4 = r2.f;
        if (r4 < 0) goto L_0x0256;
    L_0x0239:
        r4 = r2.m();
        if (r4 != 0) goto L_0x024e;
    L_0x023f:
        r4 = r2.l;
        if (r4 != 0) goto L_0x0245;
    L_0x0243:
        r4 = 0;
        goto L_0x0249;
    L_0x0245:
        r4 = r4.get();
    L_0x0249:
        if (r4 != 0) goto L_0x024e;
    L_0x024b:
        goto L_0x0256;
    L_0x024c:
        r5 = r16;
    L_0x024e:
        r0 = r0 + 1;
        r16 = r5;
        goto L_0x01f1;
    L_0x0253:
        r5 = r16;
        r2 = 0;
    L_0x0256:
        if (r2 == 0) goto L_0x029b;
    L_0x0258:
        r6 = r30.q();
        r0 = "unComplete chunk ";
        r0 = c.b.a.a.a.g(r0);
        r1 = r1.f;
        r0.append(r1);
        r0.append(r9);
        r0.append(r6);
        r1 = " reuseChunk chunkIndex:";
        r0.append(r1);
        r1 = r31;
        r0.append(r1);
        r4 = " for subChunk:";
        r0.append(r4);
        r4 = r2.f;
        r0.append(r4);
        r0 = r0.toString();
        c.j.a.d.b.g.a.d(r5, r0);
        r0 = r3.n;
        r4 = r2.a;
        r5 = r2.f;
        r6 = r2.e();
        r0.n(r4, r5, r6, r1);
        r2.f = r1;
        r0 = 1;
        r2.d(r0);
    L_0x029b:
        return r2;
    L_0x029c:
        r0 = 0;
        return r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.b.m.c.j(com.ss.android.socialbase.downloader.g.b, int):com.ss.android.socialbase.downloader.g.b");
    }

    public final List<e> k(com.ss.android.socialbase.downloader.g.b bVar) {
        com.ss.android.socialbase.downloader.g.c cVar = this.o;
        List list = cVar.i;
        String str = cVar.E;
        String str2 = c.j.a.d.b.n.a.a;
        return c.j.a.d.b.n.a.j(list, str, bVar.p(), bVar.d);
    }

    public void l() {
        i iVar = i.RUN_STATUS_PAUSE;
        this.m = iVar;
        if (this.f != null) {
            this.f.e();
        } else {
            I();
            this.m = iVar;
            H();
        }
        try {
            Iterator it = ((ArrayList) this.e.clone()).iterator();
            while (it.hasNext()) {
                b bVar = (b) it.next();
                if (bVar != null) {
                    bVar.a();
                }
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    public final void m(int i, List<com.ss.android.socialbase.downloader.g.b> list) throws com.ss.android.socialbase.downloader.e.a {
        if (list.size() == i) {
            x(list, this.o.T);
            return;
        }
        throw new com.ss.android.socialbase.downloader.e.a(1033, new IllegalArgumentException());
    }

    public final void n(long j, int i) throws com.ss.android.socialbase.downloader.e.a {
        long j2 = j;
        int i2 = i;
        long j3 = j2 / ((long) i2);
        int g0 = this.o.g0();
        ArrayList arrayList = new ArrayList();
        int i3 = 0;
        long j4 = 0;
        while (i3 < i2) {
            long j5 = i3 == i2 + -1 ? 0 : (j4 + j3) - 1;
            com.ss.android.socialbase.downloader.g.b.b bVar = new com.ss.android.socialbase.downloader.g.b.b(g0);
            bVar.f = i3;
            bVar.b = j4;
            bVar.g = j4;
            bVar.c = j4;
            bVar.d = j5;
            com.ss.android.socialbase.downloader.g.b a = bVar.a();
            arrayList.add(a);
            this.n.f(a);
            j4 += j3;
            i3++;
        }
        this.o.R = i2;
        this.n.a(g0, i2);
        x(arrayList, j2);
    }

    public final void o(long j, String str, String str2) throws com.ss.android.socialbase.downloader.e.a {
        boolean z;
        Throwable th;
        String str3;
        com.ss.android.socialbase.downloader.e.a aVar;
        long j2 = j;
        String str4 = str;
        String str5 = str2;
        String str6 = "MB";
        String str7 = ", mustSetLength = ";
        String str8 = I;
        if (!c.j.a.d.b.n.a.F(j)) {
            c.j.a.d.b.h.d d = c.j.a.d.b.n.a.d(str4, str5, -1);
            c.j.a.d.b.h.d dVar;
            try {
                long j3;
                StringBuilder stringBuilder;
                long length = new File(str4, str5).length();
                long j4 = j2 - length;
                long J = c.j.a.d.b.n.a.J(str);
                c.j.a.d.b.l.a d2 = c.j.a.d.b.l.a.d(this.o.g0());
                int b = d2.b("space_fill_part_download", 0);
                String str9 = " 0";
                String str10 = ContainerUtils.KEY_VALUE_DELIMITER;
                String str11 = "<";
                String str12 = str7;
                str7 = "availableSpace ";
                c.j.a.d.b.h.d dVar2 = d;
                long j5 = J;
                int b2;
                long j6;
                if (b == 1) {
                    try {
                        this.F = 0;
                        if (j4 <= 0) {
                            com.ss.android.socialbase.downloader.g.c cVar = this.o;
                            j4 = cVar.T - cVar.I();
                        }
                        if (j5 < j4) {
                            StringBuilder stringBuilder2 = new StringBuilder();
                            stringBuilder2.append("checkSpaceOverflow: contentLength = ");
                            stringBuilder2.append(c.j.a.d.b.n.a.a(j));
                            stringBuilder2.append("MB, downloaded = ");
                            stringBuilder2.append(c.j.a.d.b.n.a.a(length));
                            stringBuilder2.append("MB, required = ");
                            stringBuilder2.append(c.j.a.d.b.n.a.a(j4));
                            stringBuilder2.append("MB, available = ");
                            stringBuilder2.append(c.j.a.d.b.n.a.a(j5));
                            stringBuilder2.append(str6);
                            c.j.a.d.b.g.a.f(str8, stringBuilder2.toString());
                            int i = (j5 > 0 ? 1 : (j5 == 0 ? 0 : -1));
                            if (i > 0) {
                                b2 = d2.b("space_fill_min_keep_mb", 100);
                                if (b2 > 0) {
                                    J = j5 - (((long) b2) * 1048576);
                                    StringBuilder stringBuilder3 = new StringBuilder();
                                    stringBuilder3.append("checkSpaceOverflow: minKeep = ");
                                    stringBuilder3.append(b2);
                                    stringBuilder3.append("MB, canDownload = ");
                                    stringBuilder3.append(c.j.a.d.b.n.a.a(J));
                                    stringBuilder3.append(str6);
                                    c.j.a.d.b.g.a.f(str8, stringBuilder3.toString());
                                    if (J > 0) {
                                        this.F = this.o.I() + J;
                                    } else {
                                        throw new com.ss.android.socialbase.downloader.e.e(j5, j4);
                                    }
                                }
                                J = j5;
                                j2 = j;
                                if (length < j2) {
                                    J += length;
                                    if (J <= j2) {
                                        j6 = j2;
                                        j2 = J;
                                        j3 = j6;
                                        z = true;
                                        dVar = dVar2;
                                        dVar.c.setLength(j3);
                                        c.j.a.d.b.n.a.q(dVar);
                                    }
                                }
                            } else if (d2.b("download_when_space_negative", 0) == 1) {
                                j3 = j2;
                                z = false;
                                dVar = dVar2;
                                dVar.c.setLength(j3);
                                c.j.a.d.b.n.a.q(dVar);
                            } else {
                                stringBuilder = new StringBuilder();
                                stringBuilder.append(str7);
                                stringBuilder.append(i == 0 ? str10 : str11);
                                stringBuilder.append(str9);
                                throw new com.ss.android.socialbase.downloader.e.a(1052, stringBuilder.toString());
                            }
                        }
                        j3 = j2;
                    } catch (Throwable th2) {
                        th = th2;
                        dVar = dVar2;
                        c.j.a.d.b.n.a.q(dVar);
                        throw th;
                    }
                }
                j6 = j2;
                j2 = j5;
                j3 = j6;
                b2 = (j2 > 0 ? 1 : (j2 == 0 ? 0 : -1));
                if (b2 <= 0) {
                    StringBuilder stringBuilder4 = new StringBuilder();
                    stringBuilder4.append(str7);
                    stringBuilder4.append(b2 == 0 ? str10 : str11);
                    stringBuilder4.append(str9);
                    throw new com.ss.android.socialbase.downloader.e.a(1052, stringBuilder4.toString());
                } else if (j2 < j4) {
                    dVar = dVar2;
                    throw new com.ss.android.socialbase.downloader.e.e(j2, j4);
                }
                j2 = j3;
                z = true;
                dVar = dVar2;
                try {
                    dVar.c.setLength(j3);
                } catch (Throwable th3) {
                    stringBuilder = new StringBuilder();
                    stringBuilder.append("checkSpaceOverflow: setLength2 ex = ");
                    stringBuilder.append(th3);
                    stringBuilder.append(str3);
                    stringBuilder.append(z);
                    c.j.a.d.b.g.a.g(str8, stringBuilder.toString());
                    if (z) {
                        aVar = new com.ss.android.socialbase.downloader.e.a(1040, th3);
                    }
                }
                c.j.a.d.b.n.a.q(dVar);
            } catch (Throwable th4) {
                th3 = th4;
                dVar = d;
                c.j.a.d.b.n.a.q(dVar);
                throw th3;
            }
        }
    }

    public void p(com.ss.android.socialbase.downloader.e.a aVar, boolean z) {
        c.j.a.d.b.g.a.d(I, "onAllChunkRetryWithReset");
        this.m = i.RUN_STATUS_ALL_CHUNK_RETRY_WITH_RESET;
        this.w = aVar;
        e();
        if (!(z ? D(aVar) : false)) {
            d();
        }
    }

    public final void q(com.ss.android.socialbase.downloader.g.b bVar, String str, c.j.a.d.b.i.h hVar) throws com.ss.android.socialbase.downloader.e.a {
        bVar.e = this.o.T - bVar.q();
        com.ss.android.socialbase.downloader.g.c cVar = this.o;
        cVar.R = 1;
        this.n.a(cVar.g0(), 1);
        this.f = new f(this.o, str, hVar, bVar, this);
        if (this.f == null) {
            return;
        }
        if (this.m == i.RUN_STATUS_CANCELED) {
            this.o.b0(-4);
            this.f.f();
        } else if (this.m == i.RUN_STATUS_PAUSE) {
            this.o.b0(-2);
            this.f.e();
        } else {
            this.f.g();
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:10:? A:{SYNTHETIC, RETURN} */
    /* JADX WARNING: Removed duplicated region for block: B:8:0x0019  */
    public void r(c.j.a.d.b.i.f r2) {
        /*
        r1 = this;
        if (r2 == 0) goto L_0x0016;
    L_0x0002:
        r2 = r2.b();	 Catch:{ all -> 0x0012 }
        r0 = r1.o;	 Catch:{ all -> 0x0012 }
        r0.n0 = r2;	 Catch:{ all -> 0x0012 }
        r2 = c.j.a.c.y.a.i.r(r2);	 Catch:{ all -> 0x0012 }
        r0.o0 = r2;	 Catch:{ all -> 0x0012 }
        r2 = 1;
        goto L_0x0017;
    L_0x0012:
        r2 = move-exception;
        r2.printStackTrace();
    L_0x0016:
        r2 = 0;
    L_0x0017:
        if (r2 != 0) goto L_0x0022;
    L_0x0019:
        r2 = r1.o;
        r0 = -1;
        r2.n0 = r0;
        r0 = "";
        r2.o0 = r0;
    L_0x0022:
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.b.m.c.r(c.j.a.d.b.i.f):void");
    }

    /* JADX WARNING: Removed duplicated region for block: B:209:0x0451 A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:91:0x0185 A:{SYNTHETIC, Splitter:B:91:0x0185} */
    /* JADX WARNING: Missing exception handler attribute for start block: B:88:0x017d */
    /* JADX WARNING: Exception block dominator not found, dom blocks: [] */
    public void run() {
        /*
        r15 = this;
        r0 = r15.b;
        r1 = c.j.a.d.b.e.b.N;
        monitor-enter(r1);
        r2 = r1.iterator();	 Catch:{ all -> 0x047e }
    L_0x0009:
        r3 = r2.hasNext();	 Catch:{ all -> 0x047e }
        r4 = 3;
        if (r3 == 0) goto L_0x001c;
    L_0x0010:
        r3 = r2.next();	 Catch:{ all -> 0x047e }
        r3 = (c.j.a.d.b.d.f) r3;	 Catch:{ all -> 0x047e }
        if (r3 == 0) goto L_0x0009;
    L_0x0018:
        r3.b(r0, r4);	 Catch:{ all -> 0x047e }
        goto L_0x0009;
    L_0x001c:
        monitor-exit(r1);	 Catch:{ all -> 0x047e }
        r0 = I;
        r1 = 10;
        android.os.Process.setThreadPriority(r1);
        r1 = 0;
        r3 = r15.o;	 Catch:{ all -> 0x0049 }
        if (r3 == 0) goto L_0x0049;
    L_0x002a:
        r4 = r15.G;	 Catch:{ all -> 0x0049 }
        r6 = (r4 > r1 ? 1 : (r4 == r1 ? 0 : -1));
        if (r6 <= 0) goto L_0x0049;
    L_0x0030:
        r4 = java.lang.System.currentTimeMillis();	 Catch:{ all -> 0x0049 }
        r6 = r15.G;	 Catch:{ all -> 0x0049 }
        r4 = r4 - r6;
        r6 = (r4 > r1 ? 1 : (r4 == r1 ? 0 : -1));
        if (r6 <= 0) goto L_0x0049;
    L_0x003b:
        r6 = r3.b();	 Catch:{ all -> 0x0049 }
        r6 = r6 + r4;
        r4 = java.lang.Long.valueOf(r6);	 Catch:{ all -> 0x0049 }
        r5 = "dbjson_key_download_prepare_time";
        r3.t(r5, r4);	 Catch:{ all -> 0x0049 }
    L_0x0049:
        r3 = 0;
        r4 = r15.b;	 Catch:{ all -> 0x0067 }
        r4 = r4.j;	 Catch:{ all -> 0x0067 }
        if (r4 == 0) goto L_0x006b;
    L_0x0050:
        r4 = (c.j.a.d.b.n.n) r4;	 Catch:{ all -> 0x0067 }
        r4 = r4.a;	 Catch:{ RemoteException -> 0x0059 }
        r4 = r4.a();	 Catch:{ RemoteException -> 0x0059 }
        goto L_0x005e;
    L_0x0059:
        r4 = move-exception;
        r4.printStackTrace();	 Catch:{ all -> 0x0067 }
        r4 = 0;
    L_0x005e:
        if (r4 == 0) goto L_0x006b;
    L_0x0060:
        r0 = r15.u;
        r0.j();
        goto L_0x044c;
    L_0x0067:
        r4 = move-exception;
        r4.printStackTrace();	 Catch:{ all -> 0x047c }
    L_0x006b:
        r4 = r15.o;
        r4 = r4.o0();
        r5 = 1;
        if (r4 == r5) goto L_0x0094;
    L_0x0074:
        r6 = r15.o;
        r6 = r6.x();
        if (r6 != 0) goto L_0x0094;
    L_0x007c:
        r6 = -2;
        if (r4 == r6) goto L_0x0092;
    L_0x007f:
        r6 = -4;
        if (r4 == r6) goto L_0x0092;
    L_0x0082:
        r6 = new com.ss.android.socialbase.downloader.e.a;
        r7 = 1000; // 0x3e8 float:1.401E-42 double:4.94E-321;
        r8 = "The download Task can't start, because its status is not prepare:";
        r4 = c.b.a.a.a.A(r8, r4);
        r6.m4677init(r7, r4);
        r15.B(r6);
    L_0x0092:
        r4 = 0;
        goto L_0x0095;
    L_0x0094:
        r4 = 1;
    L_0x0095:
        if (r4 != 0) goto L_0x00b3;
    L_0x0097:
        r0 = r15.b;
        r0 = r0.l;
        r1 = r15.o;
        r2 = new com.ss.android.socialbase.downloader.e.a;
        r4 = 1003; // 0x3eb float:1.406E-42 double:4.955E-321;
        r5 = "task status is invalid";
        r2.m4677init(r4, r5);
        r4 = r15.o;
        if (r4 == 0) goto L_0x00ae;
    L_0x00aa:
        r3 = r4.o0();
    L_0x00ae:
        c.j.a.c.y.a.i.n(r0, r1, r2, r3);
        goto L_0x044c;
    L_0x00b3:
        r4 = c.j.a.d.b.b.i.RUN_STATUS_END_FOR_FILE_EXIST;
        r6 = c.j.a.d.b.b.i.RUN_STATUS_PAUSE;
        r7 = c.j.a.d.b.b.i.RUN_STATUS_END_RIGHT_NOW;
        r8 = c.j.a.d.b.b.i.RUN_STATUS_NONE;	 Catch:{ all -> 0x0477 }
        r15.m = r8;	 Catch:{ all -> 0x0477 }
        r8 = r15.o;	 Catch:{ all -> 0x0477 }
        java.util.Objects.requireNonNull(r8);	 Catch:{ all -> 0x0477 }
        r9 = android.os.SystemClock.uptimeMillis();	 Catch:{ all -> 0x0477 }
        r8.c0 = r9;	 Catch:{ all -> 0x0477 }
        r9 = java.lang.System.currentTimeMillis();	 Catch:{ all -> 0x0477 }
        r9 = java.lang.Long.valueOf(r9);	 Catch:{ all -> 0x0477 }
        r10 = "dbjson_last_start_download_time";
        r8.t(r10, r9);	 Catch:{ all -> 0x0477 }
        r8 = r15.o;	 Catch:{ all -> 0x0477 }
        r8.d0 = r1;	 Catch:{ all -> 0x0477 }
        r8 = java.lang.System.currentTimeMillis();	 Catch:{ all -> 0x0477 }
        r10 = r15.o;	 Catch:{ all -> 0x0477 }
        r11 = -1;
        r10.m(r11);	 Catch:{ all -> 0x0477 }
        r15.G();	 Catch:{ b -> 0x00e9 }
        r10 = 0;
        goto L_0x0105;
    L_0x00e9:
        r10 = move-exception;
        r11 = new java.lang.StringBuilder;	 Catch:{ all -> 0x0477 }
        r11.<init>();	 Catch:{ all -> 0x0477 }
        r12 = "file exist ";
        r11.append(r12);	 Catch:{ all -> 0x0477 }
        r12 = r10.c;	 Catch:{ all -> 0x0477 }
        r11.append(r12);	 Catch:{ all -> 0x0477 }
        r11 = r11.toString();	 Catch:{ all -> 0x0477 }
        c.j.a.d.b.g.a.d(r0, r11);	 Catch:{ all -> 0x0477 }
        r10 = r10.c;	 Catch:{ all -> 0x0477 }
        r15.E = r10;	 Catch:{ all -> 0x0477 }
        r10 = 1;
    L_0x0105:
        r11 = r15.C;	 Catch:{ all -> 0x0477 }
        if (r11 != 0) goto L_0x010e;
    L_0x0109:
        r11 = r15.u;	 Catch:{ all -> 0x0477 }
        r11.g();	 Catch:{ all -> 0x0477 }
    L_0x010e:
        r15.C = r3;	 Catch:{ all -> 0x0477 }
        r11 = r15.K();	 Catch:{ all -> 0x0477 }
        if (r11 == 0) goto L_0x0118;
    L_0x0116:
        goto L_0x025a;
    L_0x0118:
        r11 = r15.E;	 Catch:{ all -> 0x0477 }
        r11 = android.text.TextUtils.isEmpty(r11);	 Catch:{ all -> 0x0477 }
        if (r11 != 0) goto L_0x0156;
    L_0x0120:
        if (r10 == 0) goto L_0x0156;
    L_0x0122:
        r1 = c.j.a.d.b.l.a.f;	 Catch:{ all -> 0x0477 }
        r2 = "fix_end_for_file_exist_error";
        r1 = r1.k(r2, r5);	 Catch:{ all -> 0x0477 }
        if (r1 == 0) goto L_0x0140;
    L_0x012c:
        r1 = r15.E;	 Catch:{ all -> 0x0477 }
        r2 = r15.o;	 Catch:{ all -> 0x0477 }
        r2 = r2.b;	 Catch:{ all -> 0x0477 }
        r1 = r1.equals(r2);	 Catch:{ all -> 0x0477 }
        if (r1 == 0) goto L_0x013c;
    L_0x0138:
        r15.m = r7;	 Catch:{ all -> 0x0477 }
        goto L_0x025a;
    L_0x013c:
        r15.m = r4;	 Catch:{ all -> 0x0477 }
        goto L_0x025a;
    L_0x0140:
        r1 = r15.E;	 Catch:{ all -> 0x0477 }
        r2 = r15.o;	 Catch:{ all -> 0x0477 }
        r2 = r2.m0();	 Catch:{ all -> 0x0477 }
        r1 = r1.equals(r2);	 Catch:{ all -> 0x0477 }
        if (r1 == 0) goto L_0x0152;
    L_0x014e:
        r15.m = r7;	 Catch:{ all -> 0x0477 }
        goto L_0x025a;
    L_0x0152:
        r15.m = r4;	 Catch:{ all -> 0x0477 }
        goto L_0x025a;
    L_0x0156:
        r4 = c.j.a.d.b.i.c.a();	 Catch:{ all -> 0x0477 }
        java.util.Objects.requireNonNull(r4);	 Catch:{ all -> 0x0477 }
        r10 = r4.b;	 Catch:{ all -> 0x017d }
        r10 = r10.getAndIncrement();	 Catch:{ all -> 0x017d }
        if (r10 != 0) goto L_0x017d;
    L_0x0165:
        r10 = c.j.a.d.b.g.a.b();	 Catch:{ all -> 0x017d }
        if (r10 == 0) goto L_0x0172;
    L_0x016b:
        r10 = c.j.a.d.b.i.c.e;	 Catch:{ all -> 0x017d }
        r11 = "startSampling";
        c.j.a.d.b.g.a.d(r10, r11);	 Catch:{ all -> 0x017d }
    L_0x0172:
        r10 = r4.c;	 Catch:{ all -> 0x017d }
        r10.sendEmptyMessage(r5);	 Catch:{ all -> 0x017d }
        r10 = android.os.SystemClock.uptimeMillis();	 Catch:{ all -> 0x017d }
        r4.d = r10;	 Catch:{ all -> 0x017d }
    L_0x017d:
        r4 = r15.K();	 Catch:{ all -> 0x0477 }
        if (r4 == 0) goto L_0x0185;
    L_0x0183:
        goto L_0x025a;
    L_0x0185:
        r15.b();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r15.O();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r15.a();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r4 = r15.n;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r5 = r15.o;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r5 = r5.g0();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r4 = r4.c(r5);	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r15.c();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r5 = r15.o;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r5 = r5.f();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r10 = r15.K();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        if (r10 == 0) goto L_0x01ab;
    L_0x01a9:
        goto L_0x0257;
    L_0x01ab:
        r10 = r15.h;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        if (r10 == 0) goto L_0x01b5;
    L_0x01af:
        r1 = r15.o;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r1 = c.j.a.d.b.n.a.O(r1);	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
    L_0x01b5:
        r10 = r15.C(r1);	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r11 = r15.k(r10);	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r12 = r15.o;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        c.j.a.d.b.n.a.p(r11, r12);	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r12 = r15.o;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r12.n0(r3);	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r12 = java.lang.System.currentTimeMillis();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r15.w(r5, r11, r1);	 Catch:{ all -> 0x027f }
        r1 = r15.o;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r2 = java.lang.System.currentTimeMillis();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r2 = r2 - r12;
        r1.K(r2);	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r1 = r15.K();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        if (r1 == 0) goto L_0x01e0;
    L_0x01de:
        goto L_0x0257;
    L_0x01e0:
        r1 = r15.o;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r2 = r1.T;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r1 = r1.k0();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r14 = r15.o;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r14 = r14.l0();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r15.o(r2, r1, r14);	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r1 = r15.f(r2, r4);	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r14 = r15.K();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        if (r14 == 0) goto L_0x01fc;
    L_0x01fb:
        goto L_0x0257;
    L_0x01fc:
        if (r1 <= 0) goto L_0x0275;
    L_0x01fe:
        r14 = 1;
        if (r1 != r14) goto L_0x0203;
    L_0x0201:
        r14 = 1;
        goto L_0x0204;
    L_0x0203:
        r14 = 0;
    L_0x0204:
        r15.g = r14;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        if (r14 == 0) goto L_0x0241;
    L_0x0208:
        r1 = r15.x;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        if (r1 != 0) goto L_0x022a;
    L_0x020c:
        r12 = java.lang.System.currentTimeMillis();	 Catch:{ all -> 0x021e }
        r15.v(r5, r11);	 Catch:{ all -> 0x021e }
        r1 = r15.o;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r2 = java.lang.System.currentTimeMillis();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r2 = r2 - r12;
        r1.K(r2);	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        goto L_0x022a;
    L_0x021e:
        r1 = move-exception;
        r2 = r15.o;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r3 = java.lang.System.currentTimeMillis();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r3 = r3 - r12;
        r2.K(r3);	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        throw r1;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
    L_0x022a:
        r1 = r15.K();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        if (r1 == 0) goto L_0x0231;
    L_0x0230:
        goto L_0x0257;
    L_0x0231:
        r1 = r15.o;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r2 = java.lang.System.currentTimeMillis();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r2 = r2 - r8;
        r1.m(r2);	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r1 = r15.x;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r15.q(r10, r5, r1);	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        goto L_0x0257;
    L_0x0241:
        r5 = r15.o;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r5 = r5.H;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        if (r5 != 0) goto L_0x0251;
    L_0x0247:
        r5 = r15.x;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        if (r5 == 0) goto L_0x0251;
    L_0x024b:
        r5.d();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r5 = 0;
        r15.x = r5;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
    L_0x0251:
        r5 = r15.K();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        if (r5 == 0) goto L_0x025f;
    L_0x0257:
        r15.I();	 Catch:{ all -> 0x0477 }
    L_0x025a:
        r15.H();
        goto L_0x03a6;
    L_0x025f:
        r5 = r15.o;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r10 = java.lang.System.currentTimeMillis();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r10 = r10 - r8;
        r5.m(r10);	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r5 = r15.h;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        if (r5 == 0) goto L_0x0271;
    L_0x026d:
        r15.m(r1, r4);	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        goto L_0x0257;
    L_0x0271:
        r15.n(r2, r1);	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        goto L_0x0257;
    L_0x0275:
        r1 = new com.ss.android.socialbase.downloader.e.a;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r2 = 1032; // 0x408 float:1.446E-42 double:5.1E-321;
        r3 = "chunkCount is 0";
        r1.m4677init(r2, r3);	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        throw r1;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
    L_0x027f:
        r1 = move-exception;
        r2 = r15.o;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r3 = java.lang.System.currentTimeMillis();	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        r3 = r3 - r12;
        r2.K(r3);	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
        throw r1;	 Catch:{ a -> 0x0354, c -> 0x02af, all -> 0x028b }
    L_0x028b:
        r1 = move-exception;
        r2 = new java.lang.StringBuilder;	 Catch:{ all -> 0x0472 }
        r2.<init>();	 Catch:{ all -> 0x0472 }
        r3 = "downloadInner: throwable =  ";
        r2.append(r3);	 Catch:{ all -> 0x0472 }
        r2.append(r1);	 Catch:{ all -> 0x0472 }
        r2 = r2.toString();	 Catch:{ all -> 0x0472 }
        c.j.a.d.b.g.a.f(r0, r2);	 Catch:{ all -> 0x0472 }
        r2 = r15.m;	 Catch:{ all -> 0x0472 }
        if (r2 == r6) goto L_0x0257;
    L_0x02a4:
        r2 = new com.ss.android.socialbase.downloader.e.a;	 Catch:{ all -> 0x0472 }
        r3 = 1045; // 0x415 float:1.464E-42 double:5.163E-321;
        r2.m4678init(r3, r1);	 Catch:{ all -> 0x0472 }
        r15.B(r2);	 Catch:{ all -> 0x0472 }
        goto L_0x0257;
    L_0x02af:
        r1 = move-exception;
        r2 = new java.lang.StringBuilder;	 Catch:{ all -> 0x0472 }
        r2.<init>();	 Catch:{ all -> 0x0472 }
        r3 = "downloadInner: retry throwable for ";
        r2.append(r3);	 Catch:{ all -> 0x0472 }
        r3 = r1.a;	 Catch:{ all -> 0x0472 }
        r2.append(r3);	 Catch:{ all -> 0x0472 }
        r2 = r2.toString();	 Catch:{ all -> 0x0472 }
        c.j.a.d.b.g.a.f(r0, r2);	 Catch:{ all -> 0x0472 }
        r2 = r15.m;	 Catch:{ all -> 0x0472 }
        if (r2 == r6) goto L_0x0257;
    L_0x02ca:
        r2 = r15.d;	 Catch:{ all -> 0x0472 }
        r3 = 5;
        if (r2 == 0) goto L_0x02e6;
    L_0x02cf:
        r2 = r2.get();	 Catch:{ all -> 0x0472 }
        if (r2 <= 0) goto L_0x02e6;
    L_0x02d5:
        r1 = r15.o;	 Catch:{ all -> 0x0472 }
        r2 = r15.d;	 Catch:{ all -> 0x0472 }
        r2 = r2.decrementAndGet();	 Catch:{ all -> 0x0472 }
        r1.i0(r2);	 Catch:{ all -> 0x0472 }
        r1 = r15.o;	 Catch:{ all -> 0x0472 }
        r1.b0(r3);	 Catch:{ all -> 0x0472 }
        goto L_0x030b;
    L_0x02e6:
        r2 = r15.d;	 Catch:{ all -> 0x0472 }
        if (r2 == 0) goto L_0x0335;
    L_0x02ea:
        r2 = r15.o;	 Catch:{ all -> 0x0472 }
        r2 = r2.G();	 Catch:{ all -> 0x0472 }
        if (r2 == 0) goto L_0x0310;
    L_0x02f2:
        r1 = r15.o;	 Catch:{ all -> 0x0472 }
        r1.b0(r3);	 Catch:{ all -> 0x0472 }
        r1 = r15.d;	 Catch:{ all -> 0x0472 }
        r2 = r15.o;	 Catch:{ all -> 0x0472 }
        r2 = r2.m;	 Catch:{ all -> 0x0472 }
        r1.set(r2);	 Catch:{ all -> 0x0472 }
        r1 = r15.o;	 Catch:{ all -> 0x0472 }
        r2 = r15.d;	 Catch:{ all -> 0x0472 }
        r2 = r2.get();	 Catch:{ all -> 0x0472 }
        r1.i0(r2);	 Catch:{ all -> 0x0472 }
    L_0x030b:
        r15.I();	 Catch:{ all -> 0x0477 }
        goto L_0x0398;
    L_0x0310:
        r2 = new com.ss.android.socialbase.downloader.e.a;	 Catch:{ all -> 0x0472 }
        r3 = 1018; // 0x3fa float:1.427E-42 double:5.03E-321;
        r4 = "retry for Throwable, but retry Time %s all used, last error is %s";
        r5 = 2;
        r5 = new java.lang.Object[r5];	 Catch:{ all -> 0x0472 }
        r6 = r15.o;	 Catch:{ all -> 0x0472 }
        r6 = r6.m;	 Catch:{ all -> 0x0472 }
        r6 = java.lang.String.valueOf(r6);	 Catch:{ all -> 0x0472 }
        r7 = 0;
        r5[r7] = r6;	 Catch:{ all -> 0x0472 }
        r1 = r1.a;	 Catch:{ all -> 0x0472 }
        r6 = 1;
        r5[r6] = r1;	 Catch:{ all -> 0x0472 }
        r1 = java.lang.String.format(r4, r5);	 Catch:{ all -> 0x0472 }
        r2.m4677init(r3, r1);	 Catch:{ all -> 0x0472 }
        r15.B(r2);	 Catch:{ all -> 0x0472 }
        goto L_0x0257;
    L_0x0335:
        r2 = new com.ss.android.socialbase.downloader.e.a;	 Catch:{ all -> 0x0472 }
        r3 = 1043; // 0x413 float:1.462E-42 double:5.153E-321;
        r4 = new java.lang.StringBuilder;	 Catch:{ all -> 0x0472 }
        r4.<init>();	 Catch:{ all -> 0x0472 }
        r5 = "retry for Throwable, but retain retry time is NULL, last error is";
        r4.append(r5);	 Catch:{ all -> 0x0472 }
        r1 = r1.a;	 Catch:{ all -> 0x0472 }
        r4.append(r1);	 Catch:{ all -> 0x0472 }
        r1 = r4.toString();	 Catch:{ all -> 0x0472 }
        r2.m4677init(r3, r1);	 Catch:{ all -> 0x0472 }
        r15.B(r2);	 Catch:{ all -> 0x0472 }
        goto L_0x0257;
    L_0x0354:
        r1 = move-exception;
        r2 = new java.lang.StringBuilder;	 Catch:{ all -> 0x0472 }
        r2.<init>();	 Catch:{ all -> 0x0472 }
        r3 = "downloadInner: baseException = ";
        r2.append(r3);	 Catch:{ all -> 0x0472 }
        r2.append(r1);	 Catch:{ all -> 0x0472 }
        r2 = r2.toString();	 Catch:{ all -> 0x0472 }
        c.j.a.d.b.g.a.f(r0, r2);	 Catch:{ all -> 0x0472 }
        r2 = r15.m;	 Catch:{ all -> 0x0472 }
        if (r2 == r6) goto L_0x0257;
    L_0x036d:
        r2 = r1.a;	 Catch:{ all -> 0x0472 }
        r3 = 1025; // 0x401 float:1.436E-42 double:5.064E-321;
        if (r2 == r3) goto L_0x03a2;
    L_0x0373:
        r3 = 1009; // 0x3f1 float:1.414E-42 double:4.985E-321;
        if (r2 != r3) goto L_0x0378;
    L_0x0377:
        goto L_0x03a2;
    L_0x0378:
        r2 = r15.A(r1);	 Catch:{ all -> 0x0472 }
        if (r2 == 0) goto L_0x039d;
    L_0x037e:
        r2 = r1.a;	 Catch:{ all -> 0x0472 }
        r3 = 1051; // 0x41b float:1.473E-42 double:5.193E-321;
        if (r2 != r3) goto L_0x0386;
    L_0x0384:
        r2 = 1;
        goto L_0x0387;
    L_0x0386:
        r2 = 0;
    L_0x0387:
        if (r2 == 0) goto L_0x038c;
    L_0x0389:
        r15.d();	 Catch:{ all -> 0x0472 }
    L_0x038c:
        r2 = 0;
        r1 = r15.g(r1, r2);	 Catch:{ all -> 0x0472 }
        r2 = c.j.a.d.b.f.a.RETURN;	 Catch:{ all -> 0x0472 }
        if (r1 != r2) goto L_0x030b;
    L_0x0396:
        goto L_0x0257;
    L_0x0398:
        r1 = 0;
        r3 = 0;
        goto L_0x017d;
    L_0x039d:
        r15.B(r1);	 Catch:{ all -> 0x0472 }
        goto L_0x0257;
    L_0x03a2:
        r15.m = r7;	 Catch:{ all -> 0x0472 }
        goto L_0x0257;
    L_0x03a6:
        r1 = r15.C;
        if (r1 != 0) goto L_0x03ac;
    L_0x03aa:
        goto L_0x044c;
    L_0x03ac:
        r1 = r15.B;
        if (r1 <= 0) goto L_0x03ba;
    L_0x03b0:
        r1 = r15.B;
        r1 = r1 + -1;
        r15.B = r1;
        r1 = 0;
        goto L_0x046e;
    L_0x03ba:
        r1 = r15.o;
        r1 = r1.I();
        r3 = r15.o;
        r4 = r3.T;
        r6 = (r1 > r4 ? 1 : (r1 == r4 ? 0 : -1));
        if (r6 == 0) goto L_0x03ed;
    L_0x03c8:
        r1 = r3.c0();
        c.j.a.d.b.g.a.d(r0, r1);
        r0 = r15.u;
        r1 = new com.ss.android.socialbase.downloader.e.g;
        r2 = 1027; // 0x403 float:1.439E-42 double:5.074E-321;
        r3 = "current bytes is not equals to total bytes, bytes invalid retry status is : ";
        r3 = c.b.a.a.a.g(r3);
        r4 = r15.o;
        r4 = r4.k0;
        r3.append(r4);
        r3 = r3.toString();
        r1.m7698init(r2, r3);
        r0.d(r1);
        goto L_0x044c;
    L_0x03ed:
        r1 = r3.I();
        r3 = 0;
        r5 = (r1 > r3 ? 1 : (r1 == r3 ? 0 : -1));
        if (r5 > 0) goto L_0x041e;
    L_0x03f7:
        r1 = r15.o;
        r1 = r1.c0();
        c.j.a.d.b.g.a.d(r0, r1);
        r0 = r15.u;
        r1 = new com.ss.android.socialbase.downloader.e.g;
        r2 = 1026; // 0x402 float:1.438E-42 double:5.07E-321;
        r3 = "curBytes is 0, bytes invalid retry status is : ";
        r3 = c.b.a.a.a.g(r3);
        r4 = r15.o;
        r4 = r4.k0;
        r3.append(r4);
        r3 = r3.toString();
        r1.m7698init(r2, r3);
        r0.d(r1);
        goto L_0x044c;
    L_0x041e:
        r1 = r15.o;
        r2 = r1.T;
        r4 = 0;
        r6 = (r2 > r4 ? 1 : (r2 == r4 ? 0 : -1));
        if (r6 > 0) goto L_0x046d;
    L_0x0428:
        r1 = r1.c0();
        c.j.a.d.b.g.a.d(r0, r1);
        r0 = r15.u;
        r1 = new com.ss.android.socialbase.downloader.e.g;
        r2 = 1044; // 0x414 float:1.463E-42 double:5.16E-321;
        r3 = "TotalBytes is 0, bytes invalid retry status is : ";
        r3 = c.b.a.a.a.g(r3);
        r4 = r15.o;
        r4 = r4.k0;
        r3.append(r4);
        r3 = r3.toString();
        r1.m7698init(r2, r3);
        r0.d(r1);
    L_0x044c:
        r0 = r15.b;
        r1 = c.j.a.d.b.e.b.N;
        monitor-enter(r1);
        r2 = r1.iterator();	 Catch:{ all -> 0x046a }
    L_0x0455:
        r3 = r2.hasNext();	 Catch:{ all -> 0x046a }
        if (r3 == 0) goto L_0x0468;
    L_0x045b:
        r3 = r2.next();	 Catch:{ all -> 0x046a }
        r3 = (c.j.a.d.b.d.f) r3;	 Catch:{ all -> 0x046a }
        if (r3 == 0) goto L_0x0455;
    L_0x0463:
        r4 = 3;
        r3.a(r0, r4);	 Catch:{ all -> 0x046a }
        goto L_0x0455;
    L_0x0468:
        monitor-exit(r1);	 Catch:{ all -> 0x046a }
        return;
    L_0x046a:
        r0 = move-exception;
        monitor-exit(r1);	 Catch:{ all -> 0x046a }
        throw r0;
    L_0x046d:
        r1 = r4;
    L_0x046e:
        r3 = 0;
        r5 = 1;
        goto L_0x00b3;
    L_0x0472:
        r0 = move-exception;
        r15.I();	 Catch:{ all -> 0x0477 }
        throw r0;	 Catch:{ all -> 0x0477 }
    L_0x0477:
        r0 = move-exception;
        r15.H();
        throw r0;
    L_0x047c:
        r0 = move-exception;
        throw r0;
    L_0x047e:
        r0 = move-exception;
        monitor-exit(r1);	 Catch:{ all -> 0x047e }
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.b.m.c.run():void");
    }

    /* JADX WARNING: Removed duplicated region for block: B:49:0x0098 A:{Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }} */
    /* JADX WARNING: Removed duplicated region for block: B:36:0x0079 A:{SYNTHETIC, Splitter:B:36:0x0079} */
    /* JADX WARNING: Removed duplicated region for block: B:31:0x0060 A:{Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }} */
    /* JADX WARNING: Removed duplicated region for block: B:30:0x005f A:{Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }} */
    /* JADX WARNING: Removed duplicated region for block: B:30:0x005f A:{Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }} */
    /* JADX WARNING: Removed duplicated region for block: B:31:0x0060 A:{Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }} */
    public final void s(c.j.a.d.b.i.f r16, long r17) throws com.ss.android.socialbase.downloader.e.a, c.j.a.d.b.m.c.c {
        /*
        r15 = this;
        r1 = r15;
        r0 = r16;
        if (r0 != 0) goto L_0x0006;
    L_0x0005:
        return;
    L_0x0006:
        r2 = 0;
        r3 = r16.b();	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r4 = "Accept-Ranges";
        r4 = r0.a(r4);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r5 = "Content-Type";
        r5 = r0.a(r5);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r6 = r1.o;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r6 = r6.u;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r6 = android.text.TextUtils.isEmpty(r6);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        if (r6 == 0) goto L_0x002b;
    L_0x0021:
        r6 = android.text.TextUtils.isEmpty(r5);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        if (r6 != 0) goto L_0x002b;
    L_0x0027:
        r6 = r1.o;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r6.u = r5;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
    L_0x002b:
        r5 = c.j.a.d.b.n.a.a;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r5 = 16777216; // 0x1000000 float:2.3509887E-38 double:8.289046E-317;
        r5 = c.j.a.c.y.a.i.s(r5);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r6 = 206; // 0xce float:2.89E-43 double:1.02E-321;
        r7 = 1;
        r8 = 0;
        if (r5 == 0) goto L_0x003e;
    L_0x0039:
        if (r3 == r6) goto L_0x0052;
    L_0x003b:
        if (r3 != r7) goto L_0x0050;
    L_0x003d:
        goto L_0x0052;
    L_0x003e:
        r5 = 400; // 0x190 float:5.6E-43 double:1.976E-321;
        if (r3 < r5) goto L_0x0043;
    L_0x0042:
        goto L_0x0050;
    L_0x0043:
        if (r3 == r6) goto L_0x0052;
    L_0x0045:
        if (r3 == r7) goto L_0x0052;
    L_0x0047:
        r5 = "bytes";
        r4 = r5.equals(r4);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        if (r4 == 0) goto L_0x0050;
    L_0x004f:
        goto L_0x0052;
    L_0x0050:
        r4 = 0;
        goto L_0x0053;
    L_0x0052:
        r4 = 1;
    L_0x0053:
        r1.i = r4;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r5 = 200; // 0xc8 float:2.8E-43 double:9.9E-322;
        if (r3 == r5) goto L_0x0062;
    L_0x0059:
        r5 = 201; // 0xc9 float:2.82E-43 double:9.93E-322;
        if (r3 == r5) goto L_0x0062;
    L_0x005d:
        if (r3 != 0) goto L_0x0060;
    L_0x005f:
        goto L_0x0062;
    L_0x0060:
        r5 = 0;
        goto L_0x0063;
    L_0x0062:
        r5 = 1;
    L_0x0063:
        r1.j = r5;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r5 = r1.o;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r5.L = r4;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r4 = r5.E;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r5 = "Etag";
        r5 = r0.a(r5);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r6 = r15.y(r3, r4, r5);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r9 = "";
        if (r6 == 0) goto L_0x0098;
    L_0x0079:
        r0 = r0 instanceof c.j.a.d.b.i.h;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        if (r0 == 0) goto L_0x0090;
    L_0x007d:
        r0 = android.text.TextUtils.isEmpty(r4);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        if (r0 != 0) goto L_0x008a;
    L_0x0083:
        r0 = r4.equals(r5);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        if (r0 == 0) goto L_0x008a;
    L_0x0089:
        r5 = r9;
    L_0x008a:
        r0 = "eTag of server file changed";
        r15.u(r5, r0);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        throw r2;
    L_0x0090:
        r0 = new com.ss.android.socialbase.downloader.e.c;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r4 = 1002; // 0x3ea float:1.404E-42 double:4.95E-321;
        r0.m7696init(r4, r3, r9);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        throw r0;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
    L_0x0098:
        r4 = r1.i;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r6 = 1004; // 0x3ec float:1.407E-42 double:4.96E-321;
        if (r4 != 0) goto L_0x00c8;
    L_0x009e:
        r4 = r1.j;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        if (r4 == 0) goto L_0x00a3;
    L_0x00a2:
        goto L_0x00c8;
    L_0x00a3:
        r0 = 403; // 0x193 float:5.65E-43 double:1.99E-321;
        if (r3 != r0) goto L_0x00b1;
    L_0x00a7:
        r0 = new com.ss.android.socialbase.downloader.e.a;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r3 = 1047; // 0x417 float:1.467E-42 double:5.173E-321;
        r4 = "response code error : 403";
        r0.m4677init(r3, r4);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        throw r0;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
    L_0x00b1:
        r0 = new com.ss.android.socialbase.downloader.e.c;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r4 = new java.lang.StringBuilder;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r4.<init>();	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r5 = "response code error : ";
        r4.append(r5);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r4.append(r3);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r4 = r4.toString();	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r0.m7696init(r6, r3, r4);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        throw r0;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
    L_0x00c8:
        r3 = r1.j;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r10 = 0;
        if (r3 == 0) goto L_0x00e4;
    L_0x00ce:
        r3 = (r17 > r10 ? 1 : (r17 == r10 ? 0 : -1));
        if (r3 <= 0) goto L_0x00e4;
    L_0x00d2:
        r0 = r0 instanceof c.j.a.d.b.i.h;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        if (r0 == 0) goto L_0x00dc;
    L_0x00d6:
        r0 = "http head request not support";
        r15.u(r9, r0);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        throw r2;
    L_0x00dc:
        r0 = new com.ss.android.socialbase.downloader.e.a;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r3 = "isResponseFromBegin but firstOffset > 0";
        r0.m4677init(r6, r3);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        throw r0;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
    L_0x00e4:
        r3 = c.j.a.d.b.n.a.b(r16);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r12 = r1.o;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r12 = r12.b;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r12 = android.text.TextUtils.isEmpty(r12);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        if (r12 == 0) goto L_0x00fb;
    L_0x00f2:
        r12 = r1.o;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r12 = r12.d;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r12 = c.j.a.d.b.n.a.e(r0, r12);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        goto L_0x00fc;
    L_0x00fb:
        r12 = r9;
    L_0x00fc:
        r13 = 8;
        r13 = c.j.a.c.y.a.i.s(r13);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        if (r13 == 0) goto L_0x010b;
    L_0x0104:
        r13 = c.j.a.d.b.n.a.N(r16);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r1.k = r13;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        goto L_0x0111;
    L_0x010b:
        r13 = c.j.a.d.b.n.a.F(r3);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r1.k = r13;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
    L_0x0111:
        r13 = r1.k;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        if (r13 != 0) goto L_0x0124;
    L_0x0115:
        r14 = (r3 > r10 ? 1 : (r3 == r10 ? 0 : -1));
        if (r14 != 0) goto L_0x0124;
    L_0x0119:
        r14 = r0 instanceof c.j.a.d.b.i.h;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        if (r14 == 0) goto L_0x011e;
    L_0x011d:
        goto L_0x0124;
    L_0x011e:
        r0 = new com.ss.android.socialbase.downloader.e.a;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r0.m4677init(r6, r9);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        throw r0;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
    L_0x0124:
        if (r13 != 0) goto L_0x0141;
    L_0x0126:
        r6 = "Content-Range";
        r0 = c.j.a.d.b.n.a.A(r0, r6);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r6 = android.text.TextUtils.isEmpty(r0);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        if (r6 != 0) goto L_0x013e;
    L_0x0132:
        r6 = 2;
        r6 = c.j.a.c.y.a.i.s(r6);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        if (r6 == 0) goto L_0x013e;
    L_0x0139:
        r3 = c.j.a.d.b.n.a.c(r0);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        goto L_0x0143;
    L_0x013e:
        r3 = r17 + r3;
        goto L_0x0143;
    L_0x0141:
        r3 = -1;
    L_0x0143:
        r0 = r15.K();	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        if (r0 == 0) goto L_0x014a;
    L_0x0149:
        return;
    L_0x014a:
        r0 = r1.o;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r13 = r0.c();	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r0 = (r13 > r10 ? 1 : (r13 == r10 ? 0 : -1));
        if (r0 <= 0) goto L_0x0198;
    L_0x0154:
        r0 = r1.o;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r0 = r0.g0();	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r0 = c.j.a.d.b.l.a.d(r0);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r6 = "force_check_file_length";
        r0 = r0.b(r6, r8);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        if (r0 != r7) goto L_0x0198;
    L_0x0166:
        r0 = r1.o;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r6 = r0.c();	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r0 = (r6 > r3 ? 1 : (r6 == r3 ? 0 : -1));
        if (r0 != 0) goto L_0x0171;
    L_0x0170:
        goto L_0x0198;
    L_0x0171:
        r0 = new com.ss.android.socialbase.downloader.e.a;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r5 = 1070; // 0x42e float:1.5E-42 double:5.287E-321;
        r6 = new java.lang.StringBuilder;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r6.<init>();	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r7 = "expectFileLength = ";
        r6.append(r7);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r7 = r1.o;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r7 = r7.c();	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r6.append(r7);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r7 = " , totalLength = ";
        r6.append(r7);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r6.append(r3);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r3 = r6.toString();	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r0.m4677init(r5, r3);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        throw r0;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
    L_0x0198:
        r0 = r1.u;	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        r0.c(r3, r5, r12);	 Catch:{ a -> 0x01a7, c -> 0x01a5, all -> 0x019e }
        return;
    L_0x019e:
        r0 = move-exception;
        r3 = "HandleFirstConnection";
        c.j.a.d.b.n.a.o(r0, r3);
        throw r2;
    L_0x01a5:
        r0 = move-exception;
        throw r0;
    L_0x01a7:
        r0 = move-exception;
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.b.m.c.s(c.j.a.d.b.i.f, long):void");
    }

    public void t(b bVar) {
        if (!this.g) {
            synchronized (this) {
                this.e.remove(bVar);
            }
        }
    }

    public final void u(String str, String str2) throws c {
        this.n.d(this.o.g0());
        c.j.a.d.b.n.a.n(this.o, true);
        this.h = false;
        com.ss.android.socialbase.downloader.g.c cVar = this.o;
        cVar.p(0, true);
        cVar.T = 0;
        cVar.E = str;
        cVar.R = 1;
        cVar.X = 0;
        cVar.d0 = 0;
        cVar.Y = 0;
        this.n.a(this.o);
        throw new c(this, str2);
    }

    public final void v(String str, List<e> list) throws com.ss.android.socialbase.downloader.e.a, c {
        if (this.x == null) {
            if (this.o.R == 1) {
                c.j.a.d.b.i.a.e eVar;
                c.j.a.d.b.i.a.a aVar = c.j.a.d.b.i.a.a.b.a;
                synchronized (aVar.b) {
                    eVar = (c.j.a.d.b.i.a.e) aVar.b.remove(str);
                }
                if (eVar != null && c.j.a.d.b.n.a.x(null, list)) {
                    try {
                        throw null;
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                        System.currentTimeMillis();
                        long j = c.j.a.d.b.i.a.b.c;
                    }
                }
            }
            try {
                com.ss.android.socialbase.downloader.g.c cVar = this.o;
                c.j.a.d.b.i.h f = c.j.a.d.b.e.b.f(cVar.C, cVar.j, str, list, this.H.b("net_lib_strategy", 0), this.H.b("monitor_download_connect", 0) > 0, this.o);
                this.x = f;
                r(f);
                if (this.x == null) {
                    throw new com.ss.android.socialbase.downloader.e.a(1022, new IOException("download can't continue, firstConnection is null"));
                }
            } catch (com.ss.android.socialbase.downloader.e.a e2) {
                throw e2;
            } catch (Throwable th) {
                r(this.x);
            }
        }
    }

    public final void w(String str, List<e> list, long j) throws com.ss.android.socialbase.downloader.e.a, c {
        if (this.o.R == 1) {
            c.j.a.d.b.i.a.d a = c.j.a.d.b.i.a.a.b.a.a(str, list);
            if (a != null) {
                this.y = a;
                this.o.n0(1);
            }
        }
        if (this.y == null && !this.D && this.o.J) {
            try {
                boolean z = false;
                int b = this.H.b("net_lib_strategy", 0);
                if (this.H.b("monitor_download_connect", 0) > 0) {
                    z = true;
                }
                this.y = c.j.a.d.b.e.b.d(str, list, b, z, this.o);
            } catch (Throwable th) {
                this.o.m0 = c.j.a.d.b.n.a.Y(th);
            }
        }
        c.j.a.d.b.i.f fVar = this.y;
        if (fVar != null) {
            try {
                s(fVar, j);
            } catch (Throwable unused) {
                this.D = true;
            }
        }
        if (this.y == null || this.D) {
            v(str, list);
            s(this.x, j);
        }
    }

    public final void x(List<com.ss.android.socialbase.downloader.g.b> list, long j) throws com.ss.android.socialbase.downloader.e.a {
        Iterator it;
        i iVar = i.RUN_STATUS_PAUSE;
        i iVar2 = i.RUN_STATUS_CANCELED;
        for (com.ss.android.socialbase.downloader.g.b bVar : list) {
            if (bVar != null) {
                long j2 = bVar.d;
                if (j2 == 0) {
                    j2 = j - bVar.q();
                } else {
                    j2 = (j2 - bVar.q()) + 1;
                }
                if (j2 > 0) {
                    bVar.e = j2;
                    com.ss.android.socialbase.downloader.g.c cVar = this.o;
                    if (!cVar.H || this.x == null || (cVar.J && !this.D)) {
                        this.e.add(new b(bVar, this.b, this));
                    } else {
                        int i = bVar.f;
                        if (i == 0) {
                            c.j.a.d.b.h.c cVar2 = this.b;
                            c.j.a.d.b.i.h hVar = this.x;
                            b bVar2 = new b(bVar, cVar2, this);
                            bVar2.f = hVar;
                            this.e.add(bVar2);
                        } else if (i > 0) {
                            this.e.add(new b(bVar, this.b, this));
                        }
                    }
                }
            }
        }
        ArrayList arrayList;
        Iterator it2;
        b bVar3;
        if (c.j.a.c.y.a.i.s(64)) {
            arrayList = new ArrayList(this.e.size());
            it2 = this.e.iterator();
            while (it2.hasNext()) {
                bVar3 = (b) it2.next();
                if (this.m == iVar2) {
                    bVar3.d();
                } else if (this.m == iVar) {
                    bVar3.a();
                } else {
                    arrayList.add(bVar3);
                }
            }
            Runnable runnable = (Runnable) arrayList.remove(0);
            try {
                ExecutorService t = c.j.a.d.b.e.b.t();
                ArrayList arrayList2 = new ArrayList(arrayList.size());
                it = arrayList.iterator();
                while (it.hasNext()) {
                    arrayList2.add(t.submit((Runnable) it.next()));
                }
                while (runnable != null) {
                    if (!K()) {
                        runnable.run();
                        runnable = j.t(arrayList2);
                    } else {
                        return;
                    }
                }
                if (!arrayList2.isEmpty()) {
                    it = arrayList2.iterator();
                    while (it.hasNext()) {
                        Future future = (Future) it.next();
                        if (!(future == null || future.isDone())) {
                            try {
                                future.get();
                            } catch (Throwable unused) {
                            }
                        }
                    }
                }
            } catch (Throwable unused2) {
            }
        } else {
            arrayList = new ArrayList(this.e.size());
            it2 = this.e.iterator();
            while (it2.hasNext()) {
                bVar3 = (b) it2.next();
                if (this.m == iVar2) {
                    bVar3.d();
                } else if (this.m == iVar) {
                    bVar3.a();
                } else {
                    arrayList.add(Executors.callable(bVar3));
                }
            }
            if (!K()) {
                try {
                    ExecutorService t2 = c.j.a.d.b.e.b.t();
                    if (t2 != null) {
                        t2.invokeAll(arrayList);
                    }
                } catch (InterruptedException th) {
                    throw new com.ss.android.socialbase.downloader.e.a(1020, th);
                }
            }
        }
    }

    public final boolean y(int i, String str, String str2) {
        boolean z = true;
        if (i == 412) {
            return true;
        }
        if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2) && !str.equals(str2) && (this.j || this.i)) {
            return true;
        }
        if (!(i == 201 || i == 416) || this.o.I() <= 0) {
            z = false;
        }
        return z;
    }

    public boolean z(long j) throws com.ss.android.socialbase.downloader.e.a {
        boolean z;
        if (this.F > 0 && this.o.I() > this.F) {
            long J;
            try {
                J = c.j.a.d.b.n.a.J(this.o.k0());
            } catch (com.ss.android.socialbase.downloader.e.a unused) {
                J = 0;
            }
            String str = I;
            StringBuilder g = c.b.a.a.a.g("checkSpaceOverflowInProgress: available = ");
            g.append(c.j.a.d.b.n.a.a(J));
            String str2 = "MB";
            g.append(str2);
            c.j.a.d.b.g.a.e(str, g.toString());
            if (J > 0) {
                com.ss.android.socialbase.downloader.g.c cVar = this.o;
                long I = cVar.T - cVar.I();
                if (J < I) {
                    int b = c.j.a.d.b.l.a.d(this.o.g0()).b("space_fill_min_keep_mb", 100);
                    if (b > 0) {
                        long j2 = J - (((long) b) * 1048576);
                        g = c.b.a.a.a.h("checkSpaceOverflowInProgress: minKeep  = ", b, "MB, canDownload = ");
                        g.append(c.j.a.d.b.n.a.a(j2));
                        g.append(str2);
                        c.j.a.d.b.g.a.e(str, g.toString());
                        if (j2 > 0) {
                            this.F = (j2 + 1048576) + this.o.I();
                        } else {
                            this.F = 0;
                            throw new com.ss.android.socialbase.downloader.e.e(J, I);
                        }
                    }
                }
            }
            this.F = 0;
        }
        h hVar = this.u;
        hVar.k.addAndGet(j);
        hVar.b.S.addAndGet(j);
        j = SystemClock.uptimeMillis();
        boolean z2 = false;
        if (hVar.l) {
            boolean z3 = hVar.k.get() >= hVar.n || j - hVar.j >= ((long) hVar.m);
            if (z3) {
                hVar.j = j;
                hVar.k.set(0);
            }
            z = z3;
        } else {
            hVar.l = true;
            z = true;
        }
        long I2 = hVar.b.I();
        com.ss.android.socialbase.downloader.g.c cVar2 = hVar.b;
        if (I2 == cVar2.T) {
            try {
                hVar.c.a(cVar2.g0(), hVar.b.I());
                return false;
            } catch (Exception e) {
                e.printStackTrace();
                return false;
            }
        }
        if (hVar.i) {
            hVar.i = false;
            cVar2.b0(4);
        }
        if (hVar.b.p && z) {
            z2 = true;
        }
        hVar.b(4, null, z2);
        return z;
    }
}
